Suppose I design an email template notifying about the interview scheduled for 3 candidates to a recruiter, so in that case I send candidates array of 3 elements as a variable to my template. How do I access individual candidates name in that case?
-
You can enqueue a job + pass array of three candidates. Then within the job query each candidate and with foreach loop send email to each of them. So you pass only one candidate name to each email.Nick Surmanidze– Nick Surmanidze2018-12-03 13:09:04 +00:00Commented Dec 3, 2018 at 13:09
Add a comment
|
1 Answer
you only need to pass parameters as you would for any other, with
$candArr = Candidates::where('something','value')->get();
return view('email')->with('candidates',$candArr);
Or
$candArr = Candidates::where('something','value')->get();
return view('email',compact('candArr'));
and then in view
@foreach($candArr as $key)
{{$key->name}}
@endforeach
Hope it helps!