DefaultPermissions seed doesn't run


#1

I am working on adding permissions to my UserFrosting instance and was working off of the DefaultPermissions seed in the account sprinkle. In that process, however, I found that this seed doesn’t seem to be working. Unless I’m mistaken, the Permission class doesn’t have an id property, so the database calls in the syncPermissionsRole() function actually result in SQL errors because the permission_id is not defined.

I got around this in my seed by adding this code to the top of the function:

$permissionIds = [];
        foreach ($permissions as $slug => $permission) {
            $permissionIds[$slug] = Permission::where(['slug' => $permission->slug, 'conditions' => $permission->conditions])->first()->id;
        }

and then changing the various $permissions['PERMISSION_NAME']->id calls to be $permissionIds['PERMISSION_NAME'].

Does anyone else see this behavior?


#2

I can confirm this bug:


#3

@noonz You can open a PR or issue for this if you’d like.


#4

Thanks! I just opened the issue here: https://github.com/userfrosting/UserFrosting/issues/981