app/Providers/AuthServiceProvider.php
/**
     * Register any authentication / authorization services.
     *
     * @return void
     */
Register any authentication / authorization services.
@return void
Register any authentication / authorization services . @return void
public function boot()
    {
        $this->registerPolicies();
        Gate::define('isAdmin', function($user){
           return $user->roles()->where('name', 'admin');
        });
        Gate::define('isEditor', function($user){
            return $user->roles()->where('name', 'subscriber');
        });
    }
public function boot ( ) { $ this -> registerPolicies ( ) ; Gate :: define ( 'isAdmin' , function ( $ user ) { return $ user -> roles ( ) -> where ( 'name' , 'admin' ) ; } ) ; Gate :: define ( 'isEditor' , function ( $ user ) { return $ user -> roles ( ) -> where ( 'name' , 'subscriber' ) ; } ) ; }
Register any authentication / authorization services.
Register any authentication / authorization services .
// Création d'une règle isAdmin pour vérifier si l'user est bien un Admin // Création d'une règle isEditor pour vérifier si l'user est bien un Editeur