Search
 
SCRIPT & CODE EXAMPLE
 

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';
    }
======================================================================
Comment

PREVIOUS NEXT
Code Example
Php :: find auth laravel 
Php :: send mail infinityfree phpmailer 
Php :: toast in laravel 
Php :: PDO::ATTR_EMULATE_PREPARES = true Security issue 
Php :: phpstorm using extract to create variales 
Php :: php rand between 0 and 1 
Php :: php inverse / arc cosine 
Php :: laravel form request validation api 
Php :: get the matched value from 2 array in php 
Php :: php object example 
Php :: get attachment by id wordpress 
Php :: php convert path from server url to link 
Php :: laravel compile assets 
Php :: php check if item in array 
Php :: htaccess rewrite optional parameters 
Php :: laravel 8 search with pagination 
Php :: xdebug phpstorm 
Php :: get current month laravel 
Php :: while in php 
Php :: PHP If If Else Else Statement 
Php :: how to use or where in laravel 
Php :: parse php 
Php :: laravel get route action 
Php :: php check new month 
Php :: artisan new view 
Php :: show date php by letters 
Php :: magento show which user updated the product 
Php :: how to hide submenu admin wordpress 
Php :: mail laravel 
Php :: dynamic variable in php 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =