Laravel中的table.blade.php中的未定义变量

时间:2019-11-28 10:59:49

标签: laravel

我的档案:

@if(Auth::check() && (Auth::user()->id == $job->user_id || Auth::user()->id == Auth::user()->role_id <3 ))
    <th> Status </th>
    <th colspan="3">Action</th>
@endif

如何修复。我不明白,请!

2 个答案:

答案 0 :(得分:0)

尝试这个

@if(Auth::check() && $job && (Auth::user()->id == $job->user_id || Auth::user()->id == Auth::user()->role_id <3 ))
    <th> Status </th>
    <th colspan="3">Action</th>
@endif

答案 1 :(得分:0)

I think your blade file will not understand Auth class, instead you can change your code to something like

 @if(auth()->check() && $job && (auth()->user()->id == $job->user_id || auth()->user()->id == auth()->user()->role_id <3 ))
    <th> Status </th>
    <th colspan="3">Action</th>
 @endif

Also make sure you sending job data from your controller to view file