Roles
Usage
auth()->user()->authorizeRoles(['admin', 'teacher']);<!-- Check if user is signed in -->
@if(auth()->user())
<!-- Check for one of these roles: teacher, admin -->
@if(auth()->user()->hasAnyRole(['teacher', 'admin']) == true)
<p>This will be viewed by all admins and/or teachers!</p>
@else
<p>Anybody else will see this.</p>
@endif
<!-- Check for admin role -->
@if(auth()->user()->hasRole('admin') == true)
<p>This will be viewed by admins only.</p>
@endif
@else
<p>You need to sign in to view this section.</p>
@endifLast updated