0

Laravel SMTP issue: data displays correctly in controller but not in blade email view.

I'm working on sending emails using SMTP in Laravel. I'm able to retrieve and verify the correct data in my controller using dd(), but when I try to pass this data to my Blade email view, it doesn't display as expected.

What I have done so far:

  • I fetch the data in the controller and verify it with dd($data), which shows the correct data.

  • I pass the data to the Blade view using the standard approach:

foreach ($user_list as $id => $email) {
    $follow_up_quotes    = $this->get_follow_up_quotes($id, $currentDate);
    $multi_action_quotes = $this->get_multi_action_quotes($id, $currentDate);
    $unpaid_quotes       = $this->get_un_paid_quotes($id,$currentDate);

    // dd([
    //     'f' => $follow_up_quotes->toArray(),
    //     'm' => $multi_action_quotes->toArray(),
    //     'un' => $unpaid_quotes->toArray(),
    // ])->toArray();
    // dd($multi_action_quotes);

    if ($multi_action_quotes->isNotEmpty() || !empty($paid_quotes) || $follow_up_quotes->isNotEmpty()) {
        try {
            // Dispatch the combined email job
            AfterAndBeforeBookingSendEmailJob::dispatch($multi_action_quotes, $unpaid_quotes, $follow_up_quotes, $email, $this->mail_from);

            Log::info("Combined email job dispatched for: {$email}");
            $results[] = ["success" => "Combined email job dispatched for {$email}"];
        } catch (\Exception $e) {
            Log::error("Failed to dispatch combined email job for: {$email}. Error: {$e->getMessage()}");
            $results[] = ["error" => "Failed to dispatch combined email job for {$email}. Error: {$e->getMessage()}"];
        }
    } else {
        $results[] = ["info" => "No relevant quotes found for {$email}"];
    }
}
private function get_multi_action_quotes($user_id, $currentDate) {
    return QuoteModel::leftJoin('quote_received_loggers', 'quote_received_loggers.quote_id_fk', 'quotes.id')
                        ->leftJoin('users', 'quotes.created_by', 'users.id')
                        ->leftJoin('quotes as parent_quotes', 'quotes.p_id', '=', 'parent_quotes.id')
                        ->where('quotes.current_stage', 8)
                        ->where('quotes.active_ver', 1)
                        ->where('quotes.created_by', $user_id)
                        // ->where('quote_received_loggers.follow_up_date', '<', $currentDate)
                         ->select(
                            'quotes.id', 
                            DB::raw('CASE WHEN quotes.p_id != 0 THEN parent_quotes.full_quote_id ELSE quotes.full_quote_id END as full_quote_id'),
                            'quotes.created_by', 
                            'quotes.tour_start_date', 
                            'quote_received_loggers.follow_up_date', 
                            'quotes.ver_id', 
                            'quotes.first_ver_id', 
                            'quotes.current_ver_id'
                        )
                        ->groupBy('quotes.id')
                        ->get();

                        

}

I want to print this data but it doesn't

"f" => array:16 [▼
    0 => array:7 [▼
      "id" => 218262
      "full_quote_id" => "THONZ208066"
      "created_by" => 9
      "tour_start_date" => "2020-08-31 00:00:00"
      "follow_up_date" => "2024-08-10"
      "ver_id" => 2
      "current_ver_id" => 218262
    ]
    1 => array:7 [▼
      "id" => 229299
      "full_quote_id" => "THONZ229291"
      "created_by" => 9
      "tour_start_date" => "2020-09-16 00:00:00"
      "follow_up_date" => "2024-08-10"
      "ver_id" => 1
      "current_ver_id" => 229299
    ]
3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.