From 83ea9e2138422c335b5f21ce978fc497d177ad4b Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Wed, 11 Dec 2024 10:48:33 +0200 Subject: [PATCH] Fix add user --- .../Organizations/Resources/UserResource.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Filament/Organizations/Resources/UserResource.php b/app/Filament/Organizations/Resources/UserResource.php index 3c5a0d3b..5a392430 100644 --- a/app/Filament/Organizations/Resources/UserResource.php +++ b/app/Filament/Organizations/Resources/UserResource.php @@ -180,8 +180,8 @@ public static function getSchema(): array CheckboxList::make('case_permissions') ->label(__('user.labels.case_permissions')) ->options(CasePermission::getOptionsWithoutCaseManager()) - ->disableOptionWhen(function (Get $get, string $value, OrganizationUserPermissions $record) { - if ($record->user->isNgoAdmin()) { + ->disableOptionWhen(function (Get $get, string $value, ?OrganizationUserPermissions $record) { + if ($record?->user->isNgoAdmin()) { return true; } @@ -202,8 +202,8 @@ public static function getSchema(): array CheckboxList::make('admin_permissions') ->label(__('user.labels.admin_permissions')) ->options(AdminPermission::options()) - ->disableOptionWhen(function (Get $get, string $value, OrganizationUserPermissions $record) { - if ($record->user->isNgoAdmin()) { + ->disableOptionWhen(function (Get $get, string $value, ?OrganizationUserPermissions $record) { + if ($record?->user->isNgoAdmin()) { return true; } @@ -230,11 +230,11 @@ public static function getSchema(): array public static function setDefaultCaseAndNgoAdminPermissions(): \Closure { - return function (Set $set, Get $get, $state, User $record) { + return function (Set $set, Get $get, $state, ?User $record) { $casePermissions = $get('permissions.case_permissions') ?: []; $adminPermissions = $get('permissions.admin_permissions') ?: []; - if ($record->isNgoAdmin()) { + if ($record?->isNgoAdmin()) { $casePermissions = CasePermission::values(); $adminPermissions = AdminPermission::values();