Closed makstr closed 9 years ago
@petewwa what steps are you taking to get the above result so I can trace through the source?
I just got started and this occurs randomly. I followed your VaultTableSeeder and created some permissions and roles of my own. Then when I tried to manipulate them via the browser I received strange results such as administrator role having the View Administrator Link attached to it 3 times
$permission_model = Config::get('vault.permission');
$flyAbove = new $permission_model;
$flyAbove->name = 'fly_above_the_ground';
$flyAbove->display_name = 'Fly above the ground';
$flyAbove->system = true;
$flyAbove->created_at = \Carbon\Carbon::now();
$flyAbove->updated_at = \Carbon\Carbon::now();
$flyAbove->save();
$rolePrototyper = new $role_model;
$rolePrototyper->name = 'Prototyper';
$rolePrototyper->created_at = \Carbon\Carbon::now();
$rolePrototyper->updated_at = \Carbon\Carbon::now();
$rolePrototyper->save();
$rolePrototyper->attachPermission($flyAbove);
$user_model = Config::get('auth.model');
$user_model::first()->attachRole($rolePrototyper);
By the way what purpose does the "system" attribute in permission model have?
System is just a flag, it takes away the delete button on the UI so you don't accidentally delete it if it's really important.
Also, can you try to wipe everything, run the seed once, then use the UI to add your roles and permissions? The seeder isn't going to do many checks when using it, however the CRUD operations on the UI should prevent it from doing the above, if it isn't then theres a bug that needs to be fixed. However, the above won't crash your application because the code will still see that it exists and perform the right operations, it's just annoying and shouldn't be doing that if it is. But try this first.
Have you tried the above?