rappasoft / vault

Roles & Permissions for the Laravel 5 Framework
MIT License
103 stars 10 forks source link

Bug in seeds.stub? #11

Closed martinlindhe closed 9 years ago

martinlindhe commented 9 years ago

In the end of the seeds.stub, there is this snippet:

$user_model = Config::get('auth.model');
$user = $user_model::find(2);
$user->permissions()->sync(
    [
        $userOnlyPermission->id,
    ]
);

I think it should instead look like this, judging from how the admin role permissions is setup earlier:

$user_model = Config::get('vault.role');
$user = $user_model::find(2);
$user->permissions()->sync(
    [
        $userOnlyPermission->id,
    ]
);
rappasoft commented 9 years ago

This is different, in the one above it, the permission is being applied to the role, in this example, the permission is being applied to the user itself. So $user_model = Config::get('vault.role') is setting the user model equal to the role model and that makes no sense. Its essentially setting that permission to the role with id of 2 instead of the user with is of 2. The seeder is not the most elegant thing, but it does the job and hopefully avoids all conflicts when seeding.