Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

@admin @endadmin

1-> AppServiceProvider.php
	  public function boot()
    {
        Paginator::useBootstrap();

        Blade::if('admin',function (){
             // return auth()->check() && auth()->user()->isAdmin();
             return auth()->check() && auth()->user()->role === 'admin';
        });
    }
    
2-> now you can use in blade file
	@admin
    @else
    @endadmin
=============================================================

if you want to use isAdimin method 
you can create method in model file

User.php
 public function isAdmin():bool{
        return $this->role === 'admin';
    }
======================================================================
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
4+9 =