Added null role check to migrate path
Also added check for existing bookshelf role_permissions in the event the user got that for. Also related to #1027
This commit is contained in:
parent
9abdab3991
commit
818c02ed44
1 changed files with 7 additions and 1 deletions
|
@ -65,6 +65,10 @@ class CreateBookshelvesTable extends Migration
|
||||||
->onUpdate('cascade')->onDelete('cascade');
|
->onUpdate('cascade')->onDelete('cascade');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Delete old bookshelf permissions
|
||||||
|
// Needed to to issues upon upgrade.
|
||||||
|
DB::table('role_permissions')->where('name', 'like', 'bookshelf-%')->delete();
|
||||||
|
|
||||||
// Copy existing role permissions from Books
|
// Copy existing role permissions from Books
|
||||||
$ops = ['View All', 'View Own', 'Create All', 'Create Own', 'Update All', 'Update Own', 'Delete All', 'Delete Own'];
|
$ops = ['View All', 'View Own', 'Create All', 'Create Own', 'Update All', 'Update Own', 'Delete All', 'Delete Own'];
|
||||||
foreach ($ops as $op) {
|
foreach ($ops as $op) {
|
||||||
|
@ -81,7 +85,9 @@ class CreateBookshelvesTable extends Migration
|
||||||
'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
|
'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$rowsToInsert = $roleIdsWithBookPermission->map(function($roleId) use ($permId) {
|
$rowsToInsert = $roleIdsWithBookPermission->filter(function($roleId) {
|
||||||
|
return !is_null($roleId);
|
||||||
|
})->map(function($roleId) use ($permId) {
|
||||||
return [
|
return [
|
||||||
'role_id' => $roleId,
|
'role_id' => $roleId,
|
||||||
'permission_id' => $permId
|
'permission_id' => $permId
|
||||||
|
|
Loading…
Reference in a new issue