Search
 
SCRIPT & CODE EXAMPLE
 

PHP

custom blade directive

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 :: blade directive 
Php :: phpmailer 
Php :: laravel make model controller and migration one time 
Php :: generate report daily weekly monthly php mysql 
Php :: Full text search laravel mongodb 
Php :: laravel eloquent with nested 
Php :: view blob phpmyadmin 
Php :: php $_server 
Php :: how to use model not found exception handler laravel 
Php :: wordpress login programmatically 
Php :: blade check user role laravel 
Php :: php heredoc function 
Php :: selecting data from two tables in database php 
Php :: How to remove from a multidimensional array all duplicate elements including the original 
Php :: php get the two number of time second 
Php :: get object value by key php 
Php :: laravel id generator 
Php :: change apply coupon text woocommerce 
Php :: overloading and overriding in php 
Php :: laravel show method 
Php :: php find in array 
Php :: extend multiple classes in php 
Php :: laravel validation messages 
Php :: laravel "query()-find" 
Php :: symfony twig variable 
Php :: laravel print builder 
Php :: Get All dates of a month 
Php :: laravel enable query log 
Php :: how to write php in script file 
Php :: php glue strings 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =