Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

custom blade

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: #custom #blade
ADD COMMENT
Topic
Name
6+2 =