murilo
230
4
Laravel

User and Roles Gate

Posted 1 year ago by murilo

Hello Guys , I use to make a muth authentication like this -

https://laracasts.com/lessons/users-and-roles

but now in Laravel 5.6 , is not working this type of Authentication , maybe somethis has changed .

In AuthServiceProvider , I have this code -

use Illuminate\Support\Facades\Gate as GateContract;

  public function boot(GateContract $gate)
    {
        $this->registerPolicies();


        foreach ($this->getPermissions() as $permission){

            $gate->define($permission->title , function($user) use ($permission){
                return $user->hasRole($permission->roles);
            });

        }


    }

    protected function getPermissions(){
        return UserPermission::with('roles')->get();
    }

but is giving this error

Class 'App\Providers\Gate' not found

dows some one knows what is happenig ?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.