我正在尝试使用重定向方法将日期传递到另一页,但出现错误undefined variable
。
这是我的控制人
$exam_last = ExamResult::latest()->first();
$date_achived =$exam_last->created_at;
return redirect()->route('certificate', [$courses, $request, $course_id, $date_achived])
->with('success', 'Congratulations you\'ve passed! Your final results are '.$get_final_score. '%' )
->with( [$date_achived] );
这是我的刀刃
<div class="CompletionDate">{{$date_achived->created_at}}</div>
答案 0 :(得分:0)
尝试以key => value
的形式返回视图和数据:
$date_achived =$exam_last->created_at;
return view('admin.courses.certificate_one_template')
->with(['courses' => $courses, 'request' => $request, 'course_id' => $course_id, 'date_achived' => $date_achived])
->with('success', 'Congratulations you\'ve passed! Your final results are '.$get_final_score. '%');
在刀片服务器中,使用$date_achived
代替$date_achived->created_at
:
<div class="CompletionDate">{{$date_achived}}</div>