From 3eb2a2107e6ab9a258b4fa7f3a4af140be131395 Mon Sep 17 00:00:00 2001 From: Leandro Guindani Gehlen Date: Mon, 26 Jun 2023 08:24:39 -0300 Subject: [PATCH] Close #25: Changed folder name from `seeds` to `seeders` --- CHANGELOG.md | 2 ++ README.md | 4 ++-- .../RolesAndPermissionsSeeder.php.stub | 24 +++++++++++-------- src/ToolServiceProvider.php | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) rename database/{seeds => seeders}/RolesAndPermissionsSeeder.php.stub (68%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9edd416..dc83691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fixed issue publishing `seeders` + ## v1.3.1 (2023-06-01) - Fixed an issue where permission resource was not displayed in custom menu. diff --git a/README.md b/README.md index af01f9c..742d677 100644 --- a/README.md +++ b/README.md @@ -124,11 +124,11 @@ A new menu item called **Roles & Permissions** will appear in your Nova app afte Publish our Seeder with the following command: ``` -php artisan vendor:publish --provider="Sereny\NovaPermissions\ToolServiceProvider" --tag="seeds" +php artisan vendor:publish --provider="Sereny\NovaPermissions\ToolServiceProvider" --tag="seeders" ``` -This is just an example on how you could seed your Database with Roles and Permissions. Modify `RolesAndPermissionsSeeder.php` in `database/seeds`. List all your Models you want to have Permissions for in the `$collection` Array and change the email for the Super-Admin: +This is just an example on how you could seed your Database with Roles and Permissions. Modify `RolesAndPermissionsSeeder.php` in `database/seeders`. List all your Models you want to have Permissions for in the `$collection` Array and change the email for the Super-Admin: ```php forgetCachedPermissions(); $collection = collect([ - 'users', - 'roles', - 'permissions', - // 'teams', + 'Invoice', + 'Client', + 'Contact', + 'Payment', + 'Team', + 'User', + 'Role', + 'Permission' // ... // List all your Models you want to have Permissions for. ]); $collection->each(function ($item, $key) { // create permissions for each collection item - Permission::create(['group' => $item, 'name' => 'view ' . $item]); - Permission::create(['group' => $item, 'name' => 'view own ' . $item]); - Permission::create(['group' => $item, 'name' => 'manage ' . $item]); - Permission::create(['group' => $item, 'name' => 'manage own ' . $item]); - Permission::create(['group' => $item, 'name' => 'restore ' . $item]); - Permission::create(['group' => $item, 'name' => 'forceDelete ' . $item]); + Permission::create(['group' => $item, 'name' => 'viewAny' . $item]); + Permission::create(['group' => $item, 'name' => 'view' . $item]); + Permission::create(['group' => $item, 'name' => 'update' . $item]); + Permission::create(['group' => $item, 'name' => 'create' . $item]); + Permission::create(['group' => $item, 'name' => 'delete' . $item]); + Permission::create(['group' => $item, 'name' => 'destroy' . $item]); }); // Create a Super-Admin Role and assign all Permissions diff --git a/src/ToolServiceProvider.php b/src/ToolServiceProvider.php index 10a6f9c..1d7b133 100644 --- a/src/ToolServiceProvider.php +++ b/src/ToolServiceProvider.php @@ -26,8 +26,8 @@ public function boot(Filesystem $filesystem) ], 'migrations'); $this->publishes([ - __DIR__ . '/../database/seeds/RolesAndPermissionsSeeder.php.stub' => $this->app->databasePath() . "/seeds/RolesAndPermissionsSeeder.php", - ], 'seeds'); + __DIR__ . '/../database/seeders/RolesAndPermissionsSeeder.php.stub' => $this->app->databasePath() . "/seeders/RolesAndPermissionsSeeder.php", + ], 'seeders'); $this->app->booted(function () { $this->routes();