dimanche 16 mai 2021

How to send array variable in laravel mail template?

$carts= Cart::leftjoin('products', 'products.id', '=', 'carts.productid')
    ->leftjoin('sellers', 'sellers.id', '=', 'products.seller')
    ->select('products.*','carts.productid as productid','carts.userid as userid','carts.quantity as cartquantity','carts.subtotal as subtotal','carts.id as cartid','sellers.id as sellerid')->where('carts.userid',$_SESSION['salmonlightsuserid'])->get();
$data1 = array('carts'=>"$carts",'subtotal'=>"$subtotal",'totalquantity'=>"$totalquantity",'primaryaddress'=>"$primaryaddress");
    $useremail=$_SESSION['salmonlightsuseremail'];

     Mail::send('order-email-template',$data1, function($message) use($useremail){
     $message->to($useremail)->subject
         ('Order');
     $message->from('noreply@gamil.com');
     });

It gives error in order-email-template.blade.php Error is:- Invalid argument supplied for foreach() @foreach($carts as $cartsnew)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire