Skip to content

Commit

Permalink
Close #25: Changed folder name from seeds to seeders
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrogehlen committed Jun 26, 2023
1 parent f4d472f commit 3eb2a21
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ class RolesAndPermissionsSeeder extends Seeder
app()[\Spatie\Permission\PermissionRegistrar::class]->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
Expand Down
4 changes: 2 additions & 2 deletions src/ToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3eb2a21

Please sign in to comment.