diff --git a/composer.json b/composer.json index 8b0d992..e99adcb 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "laravel/sanctum": "^3.3.1", "laravel/tinker": "^2.8.2", "lcobucci/jwt": "^5.0", - "spatie/laravel-permission": "^5.11" + "spatie/laravel-permission": "^6.0" }, "require-dev": { "brianium/paratest": "^7.3", diff --git a/composer.lock b/composer.lock index f5511ef..f145351 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "31b71e9285c56faecbbe5b6178b5eb18", + "content-hash": "6d5742f397fb3e0fa0eab0665e9f2324", "packages": [ { "name": "brick/math", @@ -3184,35 +3184,35 @@ }, { "name": "spatie/laravel-permission", - "version": "5.11.0", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-permission.git", - "reference": "0a35e99da4cb6f85b07b3b58b718ff659c39a009" + "reference": "095821962f8f287f0ce1d6265fc7aa7070dacf12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/0a35e99da4cb6f85b07b3b58b718ff659c39a009", - "reference": "0a35e99da4cb6f85b07b3b58b718ff659c39a009", + "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/095821962f8f287f0ce1d6265fc7aa7070dacf12", + "reference": "095821962f8f287f0ce1d6265fc7aa7070dacf12", "shasum": "" }, "require": { - "illuminate/auth": "^7.0|^8.0|^9.0|^10.0", - "illuminate/container": "^7.0|^8.0|^9.0|^10.0", - "illuminate/contracts": "^7.0|^8.0|^9.0|^10.0", - "illuminate/database": "^7.0|^8.0|^9.0|^10.0", - "php": "^7.3|^8.0" + "illuminate/auth": "^8.12|^9.0|^10.0", + "illuminate/container": "^8.12|^9.0|^10.0", + "illuminate/contracts": "^8.12|^9.0|^10.0", + "illuminate/database": "^8.12|^9.0|^10.0", + "php": "^8.0" }, "require-dev": { - "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0", - "phpunit/phpunit": "^9.4", - "predis/predis": "^1.1" + "laravel/passport": "^11.0", + "orchestra/testbench": "^6.23|^7.0|^8.0", + "phpunit/phpunit": "^9.4" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.x-dev", - "dev-master": "5.x-dev" + "dev-main": "6.x-dev", + "dev-master": "6.x-dev" }, "laravel": { "providers": [ @@ -3240,7 +3240,7 @@ "role": "Developer" } ], - "description": "Permission handling for Laravel 6.0 and up", + "description": "Permission handling for Laravel 8.0 and up", "homepage": "https://github.com/spatie/laravel-permission", "keywords": [ "acl", @@ -3254,7 +3254,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-permission/issues", - "source": "https://github.com/spatie/laravel-permission/tree/5.11.0" + "source": "https://github.com/spatie/laravel-permission/tree/6.0.0" }, "funding": [ { @@ -3262,7 +3262,7 @@ "type": "github" } ], - "time": "2023-08-30T23:41:24+00:00" + "time": "2023-10-25T05:25:50+00:00" }, { "name": "symfony/console", @@ -8312,5 +8312,5 @@ "php": "^8.2" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/database/migrations/2023_02_14_051518_create_permission_tables.php b/database/migrations/2023_02_14_051518_create_permission_tables.php index 04c3278..3b010c8 100644 --- a/database/migrations/2023_02_14_051518_create_permission_tables.php +++ b/database/migrations/2023_02_14_051518_create_permission_tables.php @@ -3,7 +3,6 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -use Spatie\Permission\PermissionRegistrar; class CreatePermissionTables extends Migration { @@ -17,6 +16,8 @@ public function up() $tableNames = config('permission.table_names'); $columnNames = config('permission.column_names'); $teams = config('permission.teams'); + $pivotRole = $columnNames['role_pivot_key'] ?? 'role_id'; + $pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id'; if (empty($tableNames)) { throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.'); @@ -50,14 +51,19 @@ public function up() } }); - Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); + Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ( + $tableNames, + $columnNames, + $teams, + $pivotPermission, + ) { + $table->unsignedBigInteger($pivotPermission); $table->string('model_type'); $table->unsignedBigInteger($columnNames['model_morph_key']); $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); - $table->foreign(PermissionRegistrar::$pivotPermission) + $table->foreign($pivotPermission) ->references('id') // permission id ->on($tableNames['permissions']) ->onDelete('cascade'); @@ -65,23 +71,31 @@ public function up() $table->unsignedBigInteger($columnNames['team_foreign_key']); $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); - $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], - 'model_has_permissions_permission_model_type_primary'); + $table->primary( + [$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary' + ); } else { - $table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], - 'model_has_permissions_permission_model_type_primary'); + $table->primary( + [$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary' + ); } - }); - Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ( + $tableNames, + $columnNames, + $teams, + $pivotRole, + ) { + $table->unsignedBigInteger($pivotRole); $table->string('model_type'); $table->unsignedBigInteger($columnNames['model_morph_key']); $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); - $table->foreign(PermissionRegistrar::$pivotRole) + $table->foreign($pivotRole) ->references('id') // role id ->on($tableNames['roles']) ->onDelete('cascade'); @@ -89,29 +103,37 @@ public function up() $table->unsignedBigInteger($columnNames['team_foreign_key']); $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); - $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], - 'model_has_roles_role_model_type_primary'); + $table->primary( + [$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary' + ); } else { - $table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], - 'model_has_roles_role_model_type_primary'); + $table->primary( + [$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary' + ); } }); - Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); - $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ( + $tableNames, + $pivotPermission, + $pivotRole, + ) { + $table->unsignedBigInteger($pivotPermission); + $table->unsignedBigInteger($pivotRole); - $table->foreign(PermissionRegistrar::$pivotPermission) + $table->foreign($pivotPermission) ->references('id') // permission id ->on($tableNames['permissions']) ->onDelete('cascade'); - $table->foreign(PermissionRegistrar::$pivotRole) + $table->foreign($pivotRole) ->references('id') // role id ->on($tableNames['roles']) ->onDelete('cascade'); - $table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + $table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary'); }); app('cache')