I can send a PDF to every individual employee email id.I am using laravel 5 pdf packagesit.I am retrive the data from database and sending to the blade file.I am using for loop in the controller is not working indivual but downloading and sending only one mail.How to pass the loop to send all mail id with different contents
Routes:
Route::any('runExportPdfD2S', 'PaystubController@runExportPdfD2S');
Controller
public function runExportPdfD2S( )
{
$data=EMPS::whereRaw('TERM_DATE<REHIRE_DATE')->orWhere('TERM_DATE','=',NULL)->orderBy('ENAME', 'ASC')->get();
foreach($data as $value){
$empsid[]=$value->EmpsID;
$email[]=$value->EMAIL;
$name[]=$value->ENAME;
}
for (i=1;i<= count($empsid);i++)
{
$data['empsid']=$empsid;
$htmlContent = View::make('paystub/pdf')->with('data',$data);
$fileName = 'report.pdf';
$filePath = '../storage/app/';
PDF::loadHTML($htmlContent)
->setPaper('a4')
->setOrientation('portrait')
->save($filePath.$fileName);
$maiTemplate ='paystub/pdf';
$data['recipientName'] = 'Jean Luc Picard';
$data['recipientEmail'] = 'JeanLucPicard@ufp.star';
$data['messgae'] = 'this is the testing view';
$mailSubject = 'Mission Report';
$mailMessage = 'Please see the mission report attatched for you order.';
$mailAttachment = $filePath.$fileName;
Mail::send(
$maiTemplate, $data,
function($mailMessage) use ($email, $mailSubject, $mailAttachment)
{
$mailMessage->to($email)->subject($mailSubject);
$mailMessage->attach($mailAttachment);
}
);
}
Blade File:
@foreach ($data as $index => $value)
- <br>
{ { ++$value } }
@endforeach
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2h51sOL
via IFTTT
Aucun commentaire:
Enregistrer un commentaire