Skip to content

Commit

Permalink
Merge pull request #8 from phuclh/main
Browse files Browse the repository at this point in the history
Make the BelongsToManyMultiSelect fields can be able to preload and fix typo
  • Loading branch information
tharindarodrigo authored Apr 15, 2022
2 parents 2f479f3 + ff8dead commit c7ccdb4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvid

Now you should add any other configurations needed for the Spatie-Permission package.

You can publish the config file of the package with:
```bash
php artisan vendor:publish --tag="filament-spatie-roles-permissions-config"
```

## Usage

You can add this to your *form* method in your UserResource
Expand Down
8 changes: 0 additions & 8 deletions config/config.php

This file was deleted.

9 changes: 9 additions & 0 deletions config/filament-spatie-roles-permissions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [

'preload_roles' => false,

'preload_permissions' => false,

];
2 changes: 1 addition & 1 deletion resources/lang/en/filament-spatie.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'field.guard_name' => 'Guard Name',
'field.name' => 'Name',
'field.permissions' => 'Permissions',
'field.roles' => 'roles',
'field.roles' => 'Roles',

/*
|--------------------------------------------------------------------------
Expand Down
14 changes: 12 additions & 2 deletions src/FilamentSpatieRolesPermissionsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@
use Althinect\FilamentSpatieRolesPermissions\Resources\RoleResource;
use Filament\PluginServiceProvider;
use Illuminate\Support\ServiceProvider;
use Spatie\LaravelPackageTools\Package;

class FilamentSpatieRolesPermissionsServiceProvider extends PluginServiceProvider
{
public static string $name = 'filament-spatie-roles-permissions';

protected function getResources() :array {
public function configurePackage(Package $package): void
{
$package
->name('filament-spatie-roles-permissions')
->hasConfigFile()
->hasTranslations();
}

protected function getResources(): array
{
return [
RoleResource::class,
PermissionResource::class
];
}
}
}
1 change: 1 addition & 0 deletions src/Resources/PermissionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static function form(Form $form): Form
BelongsToManyMultiSelect::make('roles')
->label(__('filament-spatie-roles-permissions::filament-spatie.field.roles'))
->relationship('roles', 'name')
->preload(config('filament-spatie-roles-permissions.preload_roles'))
])
])
]);
Expand Down
1 change: 1 addition & 0 deletions src/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static function form(Form $form): Form
BelongsToManyMultiSelect::make('permissions')
->label(__('filament-spatie-roles-permissions::filament-spatie.field.permissions'))
->relationship('permissions', 'name')
->preload(config('filament-spatie-roles-permissions.preload_permissions'))
])
])
]);
Expand Down

0 comments on commit c7ccdb4

Please sign in to comment.