Skip to content

Commit 621a7c1

Browse files
author
Given Ncube
committed
fix: pluralized the model name if it's all
1 parent a3f0d5c commit 621a7c1

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Commands/GeneratePermissionsCommand.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function handle(): int
5555
protected function generatePermissionsForAllModels(): void
5656
{
5757
$this->getModels()->each(
58-
fn (string $model) => $this->generatePermissions($model)
58+
fn(string $model) => $this->generatePermissions($model)
5959
);
6060
}
6161

@@ -70,7 +70,7 @@ public function generatePermissions(string $model): void
7070
$permissions = config('authorizer.permissions');
7171

7272
collect($permissions)->each(
73-
fn (string $permission) => $this->generatePermission(
73+
fn(string $permission) => $this->generatePermission(
7474
$model,
7575
$permission
7676
)
@@ -86,17 +86,14 @@ public function generatePermissions(string $model): void
8686
*/
8787
public function generatePermission(string $model, string $permission): mixed
8888
{
89-
if (
90-
Str::contains($permission, 'any') ||
91-
Str::contains($permission, 'all')
92-
) {
89+
if (Str::contains($permission, 'all')) {
9390
return Permission::findOrCreate(
94-
$permission.' '.Str::snake(Str::plural(Str::lower($model)))
91+
$permission . ' ' . Str::snake(Str::plural(Str::lower($model)))
9592
);
9693
}
9794

9895
return Permission::findOrCreate(
99-
$permission.' '.Str::snake(Str::lower($model))
96+
$permission . ' ' . Str::snake(Str::lower($model))
10097
);
10198
}
10299
}

0 commit comments

Comments
 (0)