I want the code to check if the current user category is admin
or superadmin
, it will show the edit panel
@if (Auth::user()->category=='admin'||Auth::user()->category=='superadmin')
<td class="center">
<a href="{{ route('Order.edit', ['id'=>$order->id ]) }}" class="btn btn-warning btn-sm custom">
<i class="glyphicon glyphicon-edit"></i> EDIT</a>
</td>
else, it will display message like this
@else
<td class="center">
<b><p>This is only for admin</p></b>
</td>
I have table user
and in the table I have category
.
But it looks like it cannot check for the condition correctly.
It always display message even the user category is admin
or superadmin
2
Answers
Auth::user()->category==’admin’ X
Auth::user()->category->name==’admin’ , or the column name where ‘admin’ is .
protected $fillable = [ ‘name’, ’email’, ‘password’, ‘type’, ]; protected $hidden = [ ‘password’, ‘remember_token’, ];
In your user table you mentioned “type” and in your condition you are checking “category” if i am not wrong then change your “category” to “type” in Your Condition like mentioned below
@if (Auth::user()->type==’admin’||Auth::user()->type==’superadmin’)