Skip to content

Commit 5b5bdff

Browse files
author
Given Ncube
committed
fix: used defined methods
1 parent 58035aa commit 5b5bdff

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

phpunit.xml.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,4 @@
3636
<logging>
3737
<junit outputFile="build/report.junit.xml"/>
3838
</logging>
39-
40-
<php>
41-
<env name="DB_CONNECTION" value="testing"/>
42-
<env name="DB_DATABASE" value="database/database.sqlite"/>
43-
</php>
4439
</phpunit>

src/Commands/GeneratePermissionsCommand.php

Lines changed: 8 additions & 10 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
)
@@ -90,15 +90,13 @@ public function generatePermission(string $model, string $permission): mixed
9090
Str::contains($permission, 'any') ||
9191
Str::contains($permission, 'all')
9292
) {
93-
return Permission::updateOrCreate([
94-
'name' => $permission.
95-
' '.
96-
Str::snake(Str::plural(Str::lower($model))),
97-
]);
93+
return Permission::findOrCreate(
94+
$permission . ' ' . Str::snake(Str::plural(Str::lower($model)))
95+
);
9896
}
9997

100-
return Permission::updateOrCreate([
101-
'name' => $permission.' '.Str::snake(Str::lower($model)),
102-
]);
98+
return Permission::findOrCreate(
99+
$permission . ' ' . Str::snake(Str::lower($model))
100+
);
103101
}
104102
}

0 commit comments

Comments
 (0)