jeudi 8 juin 2017

Laravel - Redirect with variable to twig page

I've made a mail function with an try/catch situation. It checks if the mail template exists, if not it needs to return redirect / back to the page with a message(return redirect('dashboard')->with('status', "Mail doesn't exists");)

Is it possible to redirect with a variable using a twig page? Or is there just something that I am doing wrong?

This is my mail function(DashboardController.php)

 public function MailContact($date_id, $contact_id)
{
    try
    {
        $contact = Contact::find($contact_id);
        $date = Date::find($date_id);
        $mail = Mails::where('datetype_id', $date->datetype_id)->first();
        $html = $mail->html;

        Mail::to($contact->email)->send(new Anniversary($html));

        return redirect('dashboard');
        }
    catch(\Exception $ex )
    {
        return redirect('dashboard')->with("Mail doesn't exists");
    }
}

This is the twig page('dashboard.twig')

 <div class="box-body no-padding" style="width: 100%; padding-top:20px;">
  <ul class="telephoneKingList" style=" display: inline-block;
    width: 100%;">
        
              <li>
                 Geen data beschikbaar.
              </li>
                                    
  </ul>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire