php - yajra 中的 Undefiend 变量
问题描述
下面是向学生显示当前考试的代码。如果他已经申请,那么他不能申请相同。当用户登录时,我将值存储在 Session.put('Student.id',$user[0]->id )。现在当我运行下面的代码时,我得到了错误:
未定义变量:警报中的$admission_id(我使用了 YAJRA DATATABLE)。
**$admission_id** = Session::get('student.id');
$exam=DB::table('exam')->where('id_exam_category','2')->get();
return Datatables::of($exam)
->addIndexColumn()
->addColumn('exam_name', function($row){
return $row->exam_name;
})
->addColumn('action',function($row){
$stu=DB::table('exam_student')
->where('id_exam',$row->id)
->where('admission_id',**$admission_id**)
->get();
if(count($stu) > 0) {
$ret='<button class="btn btn-block btn-default" disabled>Appered <i class="fa fa-caret-right"></i></a>';
}else{
$ret='<a href="'.url('instruction',[$row->id]).'" class="btn btn-block btn-primary">Start <i class="fa fa-caret-right"></i></a>';
}
return $ret;
})
->rawColumns(['action'])
->make(true);
即使我打印 $admission_id...它正在打印。Session.id 有学生证,不为空。有什么建议吗?谢谢你
解决方案
推荐阅读
- php - 获取一个月的最后一天
- http - 闲置一段时间后如何让Go的http.Server退出?
- javascript - 我的倒数计时器无法工作或显示
- c++ - 使用 c++ 和 MPI 的交通控制模拟器。显示来自每个节点的值,但收集函数不会将所有值收集到一个数组
- java - 如何构建两个构建 android 变体以使用 Retrofit 获取两个不同的 URL?
- java - 在 Spring Boot 中使用 application.yml 配置嵌入式 Tomcat 的日志记录
- javascript - 如何使用 java 脚本从函数内部获取值?
- mysql - 如果列不为空,mysql SELECT 并总结
- html - 如何将我的游戏上传到 Facebook Instant Games
- c++ - 有没有办法使用 Johnny-5 发送 C/C++ 命令?