AdRock

Problems with Entrust

Posted 2 years ago by AdRock

I am trying to use Entrust to add roles to my users but I've hit a brick wall.

I've been following the instructions on GitHub https://github.com/Zizaco/entrust#usage and I've got up the the usage section.

I need to add some users but I get the following error

FatalErrorException in EloquentUserProvider.php line 130: Class '\App\User' not found

I updated my User.php to this (in default location)

<?php

use Zizaco\Entrust\Traits\EntrustUserTrait;

class User extends Eloquent
{
    use EntrustUserTrait; // add this trait to your user model

    ...
}

Also after this problem is fixed and I have users in database, how do i run the following code to create roles etc. Would i create a controller and run it?

$owner = new Role();
$owner->name         = 'owner';
$owner->display_name = 'Project Owner'; // optional
$owner->description  = 'User is the owner of a given project'; // optional
$owner->save();

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