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?
答案 0 :(得分:0)
您只需使用
就可以像其他任何参数一样传递参数$candArr = Candidates::where('something','value')->get();
return view('email')->with('candidates',$candArr);
或
$candArr = Candidates::where('something','value')->get();
return view('email',compact('candArr'));
然后在视图中
@foreach($candArr as $key)
{{$key->name}}
@endforeach
希望有帮助!