create created model event and adding role and permission seeder
This commit is contained in:
@@ -6,5 +6,17 @@ use Spatie\Permission\Models\Permission as Model;
|
||||
|
||||
class Permission extends Model
|
||||
{
|
||||
//
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::created(function (Permission $permission) {
|
||||
if ($role = Role::where('name', 'superuser')->first()) {
|
||||
$role->permissions()->attach([$permission->id]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user