Skip to content

Commit

Permalink
Allow name to be nullable in StoreUserRequest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
mawuva committed Jan 29, 2022
1 parent 46ec70d commit 72a9947
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Http/Requests/StoreUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function rules(): array
$usersTable = config('custom-user.user.table.name');

$rules = [
'name' => ['string'],
'name' => 'string|nullable',

'email' => [
'required', 'string', 'email', Rule::unique($usersTable, 'email')
Expand All @@ -60,9 +60,6 @@ public function rules(): array
'is_admin' => 'integer|nullable',
];

(!get_attribute('name', 'optional'))
?? array_push($rules['name'], 'required');

(get_attribute('phone_number', 'unique'))
?? array_push($rules['phone_number'], Rule::unique($usersTable, 'phone_number'));

Expand Down Expand Up @@ -101,7 +98,7 @@ public function toDTO(): CreateUserDTO
'phone_number' => $this ->phone_number,
'gender' => $this ->gender,
'account_type' => $this ->account_type,
'role' => $this ->role,
'role' => $this ->role,
'is_admin' => $this ->is_admin,
]);
}
Expand Down

0 comments on commit 72a9947

Please sign in to comment.