首页 > 解决方案 > 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 有学生证,不为空。有什么建议吗?谢谢你

标签: phplaravel

解决方案


推荐阅读