From ed457199c1d107d3676dff31df643312c2f0912f Mon Sep 17 00:00:00 2001 From: a6a2f5842 Date: Mon, 16 Jun 2025 08:31:14 +0200 Subject: [PATCH] R publishing, BF namespace --- ..._06_16_000001_create_blax_role_tables.php} | 6 +++--- src/Models/Permission.php | 1 - src/PermissionsServiceProvider.php | 20 ++++++++++--------- src/Traits/HasRoles.php | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) rename database/migrations/{create_blax_role_tables.php.stub => 2025_06_16_000001_create_blax_role_tables.php} (95%) diff --git a/database/migrations/create_blax_role_tables.php.stub b/database/migrations/2025_06_16_000001_create_blax_role_tables.php similarity index 95% rename from database/migrations/create_blax_role_tables.php.stub rename to database/migrations/2025_06_16_000001_create_blax_role_tables.php index 14035af..a196812 100644 --- a/database/migrations/create_blax_role_tables.php.stub +++ b/database/migrations/2025_06_16_000001_create_blax_role_tables.php @@ -16,7 +16,7 @@ return new class extends Migration // Permission Schema::create(config('roles.table_names.permissions'), function (Blueprint $table) { $table->id(); - $table->string('name')->unique(); + $table->string('slug')->unique(); $table->string('description')->nullable(); $table->timestamps(); }); @@ -37,8 +37,8 @@ return new class extends Migration ->nullable() ->constrained('roles') ->onDelete('set null'); - $table->string('name'); - $table->string('slug',32)->unique(); + $table->string('name')->nullable(); + $table->string('slug')->unique(); $table->string('description')->nullable(); $table->timestamps(); }); diff --git a/src/Models/Permission.php b/src/Models/Permission.php index 8f8f12c..b36628c 100644 --- a/src/Models/Permission.php +++ b/src/Models/Permission.php @@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Model; class Permission extends Model { protected $fillable = [ - 'name', 'slug', 'description', ]; diff --git a/src/PermissionsServiceProvider.php b/src/PermissionsServiceProvider.php index ae154fb..d42a380 100644 --- a/src/PermissionsServiceProvider.php +++ b/src/PermissionsServiceProvider.php @@ -36,22 +36,24 @@ class PermissionsServiceProvider extends \Illuminate\Support\ServiceProvider */ protected function offerPublishing() { - if (! $this->app->runningInConsole()) { - return; - } - - if (! function_exists('config_path')) { - // function not available and 'publish' not relevant in Lumen + if ( + ! $this->app->runningInConsole() + ) { return; } $this->publishes([ - __DIR__.'/../config/roles.php' => config_path('roles.php'), + __DIR__.'/../config/roles.php' => $this->app->configPath('roles.php'), ], 'roles-config'); - $this->publishes([ - __DIR__.'/../database/migrations/create_blax_role_tables.php.stub' => $this->getMigrationFileName('create_blax_role_tables.php'), + $publishesMigrationsMethod = method_exists($this, 'publishesMigrations') + ? 'publishesMigrations' + : 'publishes'; + + $this->{$publishesMigrationsMethod}([ + __DIR__.'/../database/migrations' => $this->app->databasePath('migrations'), ], 'roles-migrations'); + } /** diff --git a/src/Traits/HasRoles.php b/src/Traits/HasRoles.php index 6b06cd3..745aee3 100644 --- a/src/Traits/HasRoles.php +++ b/src/Traits/HasRoles.php @@ -1,6 +1,6 @@