2015-06-21 37 views
-1

我想用我的郵件功能裏面的foreach,但我不知道該怎麼做,(我用swiftmailer,但是這並不是真正相關的,我認爲)Laravel把裏面的foreach郵件

這裏我的代碼:

Mail::send('emails.bestelling', 
     array(
      'mededeling' => $bestelcode, 
      'rekeningnummer' => '000/000000/00', 
      'naam' => $userNaam, 
      'totaal' => $totaal, 
      'producten' => 
      foreach ($mand as $rij) 
      { 
       $rij->name; 
       $rij->qty; 
      } 


     } 


     ), function($message) 
    { 
     $message->from('[email protected]'); 
     $message->to('[email protected]', 'Admin')->subject('Creative Displays Bestelling'); 
    }); 

回答

1

郵件外使用的foreach()如下:

$production_string = ''; 
foreach ($mand as $rij) 
{ 
    $production_string .= "Name : ".$rij->name; 
    $production_string .= ", Quantity : ".$rij->qty; 
} 

Mail::send('emails.bestelling', 
     array(
      'mededeling' => $bestelcode, 
      'rekeningnummer' => '000/000000/00', 
      'naam' => $userNaam, 
      'totaal' => $totaal, 
      'producten' => $production_string 
     } 
    ), function($message) 
    { 
     $message->from('[email protected]'); 
     $message->to('[email protected]', 'Admin')->subject('Creative Displays Bestelling'); 
    }); 
+0

的感謝!有一點補充是將$ production_string =''; 之前的foreach,否則他變量不存在 – Christophvh

+0

:)這是偉大的。它爲你工作。 – AnkiiG