Skip to content

Commit

Permalink
fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh committed Jan 25, 2024
1 parent 17a1836 commit ad9f6ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static function getCheckBoxListComponentForResource(array $entity): Compo
{
$permissionsArray = static::getResourcePermissionOptions($entity);

return static::getCheckboxListFormComponent($entity['resource'], $permissionsArray);
return static::getCheckboxListFormComponent($entity['resource'], $permissionsArray, false);
}

public static function getTabFormComponentForPage(): Component
Expand All @@ -317,7 +317,6 @@ public static function getTabFormComponentForPage(): Component
->badge($count)
->schema([
static::getCheckboxListFormComponent('pages_tab', $options)
->searchable(),
]);
}

Expand All @@ -331,7 +330,6 @@ public static function getTabFormComponentForWidget(): Component
->badge($count)
->schema([
static::getCheckboxListFormComponent('widgets_tab', $options)
->searchable(),
]);
}

Expand All @@ -344,16 +342,16 @@ public static function getTabFormComponentForCustomPermissions(): Component
->visible(fn (): bool => (bool) Utils::isCustomPermissionEntityEnabled() && $count > 0)
->badge($count)
->schema([
static::getCheckboxListFormComponent('custom_permissions', $options)
->searchable(),
static::getCheckboxListFormComponent('custom_permissions', $options),
]);
}

public static function getCheckboxListFormComponent(string $name, array $options): Component
public static function getCheckboxListFormComponent(string $name, array $options, bool $searchable = true): Component
{
return Forms\Components\CheckboxList::make($name)
->label('')
->options(fn (): array => $options)
->searchable($searchable)
->afterStateHydrated(
fn (Component $component, string $operation, ?Model $record) => static::setPermissionStateForRecordPermissions(
component: $component,
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/RoleResource/Pages/CreateRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ protected function mutateFormDataBeforeCreate(array $data): array
return ! in_array($key, ['name', 'guard_name', 'select_all']);
})
->values()
->flatten();
->flatten()
->unique();

return Arr::only($data, ['name', 'guard_name']);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/RoleResource/Pages/EditRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ protected function mutateFormDataBeforeSave(array $data): array
return ! in_array($key, ['name', 'guard_name', 'select_all']);
})
->values()
->flatten();
->flatten()
->unique();

return Arr::only($data, ['name', 'guard_name']);
}
Expand Down

0 comments on commit ad9f6ff

Please sign in to comment.