I want to make ADD button only visible to admin-type user. My code looks like this:
@foreach($users as $user)
@if(Auth::user()->type=='admin')
<a href="{{ route('User.create', ['id'=>$user->id ]) }}" class="btn btn-default</i> ADD</a>
@endif
@endforeach
But, it returns lot of ADD button according to number of all users because of foreach loop. If I remove foreach loop, it will show error:
Undefined variable: user
How can I solve this problem?