PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 16, 2022

[FIXED] How to send array variable in laravel mail template?

 February 16, 2022     eloquent, laravel, laravel-4, laravel-5, mysql     No comments   

Issue

$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)


Solution

You don't need double quotes. Must be 'carts' => $carts.



Answered By - Nikita Ivanov
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing