Skip to content

Commit

Permalink
UPDATED README
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh committed Dec 19, 2023
1 parent 949b2dd commit e4d6ee8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ class IncomeWidget extends LineChartWidget
}
```

#### Role Policy
### Policies

You can skip this if have set the `enabled => true` in the config.
#### Role Policy
To ensure `RoleResource` access via `RolePolicy` you would need to add the following to your `AuthServiceProvider`:

```php
Expand All @@ -342,6 +342,30 @@ protected $policies = [
...
```

**You can skip it if you have enabled it from the `config`:**

```php
// config/filament-shield.php
...

'register_role_policy' => [
'enabled' => true,
],
...
```

#### Policy Path
If your policies are not in the default `Policies` directory in the `app_path()` you can change the directory name in the config file:

```php
...
'generator' => [
'option' => 'policies_and_permissions',
'policy_directory' => 'Policies',
],
...
```

#### Custom folder structure for Models or Third-Party Plugins

Shield also generates policies and permissions for third-party plugins and `Models` with custom folder structure and to enforce the generated policies you will need to register them in your application's `AuthServiceProvider`:
Expand Down
2 changes: 1 addition & 1 deletion config/filament-shield.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

'generator' => [
'option' => 'policies_and_permissions',
'policy_path_prefix' => 'Policies',
'policy_directory' => 'Policies',
],

'exclude' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Concerns/CanGeneratePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function generatePolicyPath(array $entity): string
{
$path = (new \ReflectionClass($entity['fqcn']::getModel()))->getFileName();

$policyPath = Str::of(config('filament-shield.generator.policy_path_prefix', 'Policies'))
$policyPath = Str::of(config('filament-shield.generator.policy_directory', 'Policies'))
->replace('\\', DIRECTORY_SEPARATOR);

if (Str::of($path)->contains(['vendor', 'src'])) {
Expand Down

0 comments on commit e4d6ee8

Please sign in to comment.