Search
 
SCRIPT & CODE EXAMPLE
 

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

PREVIOUS NEXT
Code Example
Php :: laravel filter 
Php :: phpmailer doesnt work 
Php :: php check if type is mysqli_result 
Php :: laravel collection isNotEmpty 
Php :: octobercms mail view 
Php :: ?: php 
Php :: Woocommerce Adding Content to the Custom Endpoint 
Php :: php current page 
Php :: laravel validation on update 
Php :: php read big file line by line 
Php :: docker php-fpm-apline add imagick 
Php :: laravel translation parameter send 
Php :: How to make a simple mail system in Laravel without view or notification 
Php :: php test questions 
Php :: laravel how to check app env 
Php :: jsondecode 
Php :: encapsulation in php 
Php :: run queue after x minutes laravel 
Php :: delete laravel error log 
Php :: laravel hiding attributes JSON 
Php :: wp wordPress variables de session 
Php :: pagination using ajax 
Php :: php base58 decode 
Php :: enable socket in php 
Php :: php class 
Php :: php round function syntax 
Php :: function to find the mod of a number in php 
Php :: send gmail 
Php :: codeigniter sms send 
Php :: laravel showing index of problem 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =