我想在控制器的数据表的添加列中使用其他方法,但这会发生
///当授权用户与用户分配相同时,使用ELSE禁用按钮
//我的控制器
@if({$a->user_assign}!=Auth::user->assign_to)
<button data-toggle='modal' data-target='#transfer' class='btn btn-success btnx' data-item_name='$a->item_name' data-id='$a->id' disable>Transfer</i>
@else
<button data-toggle='modal' data-target='#transfer' class='btn btn-success btnx' data-item_name='$a->item_name' data-id='$a->id'>Transfer</i>
@endif
<button data-toggle='modal' data-target='#viewmodal$a->id' class='btn btn-info btnaction'><i class='fa fa-eye' ></i></button>
</button>
// MY BLADE
<th>Assign to.</th>
<th>Action</th>
</tr>
</thead>
@foreach($departmentres as $a)
</table>
答案 0 :(得分:0)
Blade模板存在多个问题,您需要回显php变量和对象属性
@if($a->user_assign != auth()->user()->assign_to)
<button data-toggle='modal' data-target='#transfer' class='btn btn-success btnx' data-item_name='{{ $a->item_name }}'
data-id='{{ $a->id }}' disable>Transfer</i>
</button>
@else
<button data-toggle='modal' data-target='#transfer' class='btn btn-success btnx' data-item_name='{{ $a->item_name }}'
data-id='{{ $a->id }}'>Transfer</i>
</button>
@endif
<button data-toggle='modal' data-target='#viewmodal{{ $a->id }}' class='btn btn-info btnaction'><i
class='fa fa-eye'></i></button>
希望这会有所帮助