jeudi 6 mai 2021

Locale Get Ignored When Sending Mail with Queue

I'm looking for an answer. Laravel Framework 5.5.44 and I have a queue that will send an email whenever someone place new order on my website. I used event and listener to accomplish this. My queue successfully sent the email but my locale code does not working. Below is my code :

NewOrderListener.php

 public function handle($event)
    {
        

        try {
            dump('new order registered (listernerrr)');

            // dump($event->order);

            $email = $event->order['email'];
            // $logo_settings_details = Settings::get_logo_settings_details();
            // // dump($logo_settings_details);
            // $event->order->prepend('logo_settings_details', DB::table('gr_logo_settings')->get());
            // array_push($event->order, DB::table('gr_logo_settings')->get());
            $event->order['logo_settings_details'] = DB::table('gr_logo_settings')->get();
            // $data = [
            //     'logo_settings_details' => DB::table('gr_logo_settings')->get(),
            // ];
            // dd($data);
            $get_images = DB::table('gr_no_images')->select('banner_image','restaurant_store_image','restaurant_item_image','product_image','logo_image','landing_image','shop_logo_image','category_image')->first();
            if(empty($get_images) === false)
            { 
                $no_item = $get_images->restaurant_item_image;
                $event->order['no_item'] = $no_item;

            }

            
            $this->general_setting = DB::table('gr_general_setting')->get();
            if(count($this->general_setting) > 0){
                foreach($this->general_setting as $s){
                    $event->order['FOOTERNAME'] = $s->footer_text;  
                }
            }
            else {
                 $event->order['FOOTERNAME'] = 'ePickMeUp';
            }
            

            // dd($event->order);

            Mail::send('email.order_mail_customer', $event->order, function($message) use($email)
            {
                dump($email);
                // $sub_data = (Lang::has(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS')) ? trans(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS') : trans($this->FRONT_LANGUAGE.'.FRONT_ORDER_SUCCSESS');

                // dump($sub_data);

                $message->to('googleadmin@gmail.com')->subject('SUCCESSFUL ORDER 😍');
                dump('email sent');

            });

        } catch (\Exception $e) {
            // Log Error
            // Log::error($e->getMessage());

            // Sent Error To Slack

            // Dump Error
            dump($e->getMessage());
        }

    }

order_mail_customer.blade.php

    <td style="border-top: 5px solid #f7d501;">
        <table style="padding:10px;width:100%;">
            <tr>
                <td align="center">
                    @php $path = url('').'/public/images/noimage/default_image_logo.jpg'; @endphp
                    @if(count($logo_settings_details) > 0)
                    @php
                        foreach($logo_settings_details as $logo_set_val){ }
                    @endphp
                    @if($logo_set_val->admin_logo != '')
                        @php $filename = public_path('images/logo/').$logo_set_val->admin_logo; @endphp 
                        @if(file_exists($filename))
                        @php $path = url('').'/public/images/logo/'.$logo_set_val->admin_logo; @endphp
                        @endif
                    @endif                          
                    @endif
                    <img src="" alt="@lang(Session::get('front_lang_file').'.ADMIN_LOGO')" class="img-responsive logo"  width="100">
                </td>                       
            </tr>
        </table>
        </td>
    </tr>
    
    @if($self_pickup==1)
        <tr>
            <td>
                <table style="width:100%;background:url('')no-repeat; padding:56px 20px;">
                    <tr>
                        <td colspan="1" style="text-align:center; font-family:cursive; font-size:35px; padding-bottom: 20px;  color: #fff;">
                            @lang(Session::get('front_lang_file').'.FRONT_THANK_ORDER')
                        </td>                           
                    </tr>
                    <tr>
                        <td style="text-align:center; font-family:sans-serif; font-size:17px; padding-bottom: 20px;  color: #fff; line-height: 25px;">
                            @lang(Session::get('front_lang_file').'.API_ORDER_PLACED')
                            
                        </td>
                    </tr>
                    <tr>
                    <td style="text-align:center; font-family:sans-serif; font-size:17px; padding-bottom: 20px;  color: #fff; line-height: 25px;">
                        @lang(Session::get('front_lang_file').'.ADMIN_TRANSACTION_ID')&nbsp;:&nbsp;
                    </td>
                </tr>
                </table>
            </td>
        </tr>

Why all those @lang(Session::get('front_lang_file') not getting called on queue? Hopefully, someone could help me to solve this problem. Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3thVte0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire