-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
334bd6b
commit 97da422
Showing
6 changed files
with
632 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\User; | ||
|
||
use App\Core\Query\OrderDirection; | ||
use App\Core\User\Query\UserOrderBy; | ||
use App\Http\Requests\BaseRequest; | ||
use App\Port\Core\User\GetAllUserPort; | ||
use App\Rules\Enum\BackedEnumRule; | ||
use ValueError; | ||
|
||
class GetAllUserRequest extends BaseRequest implements GetAllUserPort | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'orderBy' => ['bail', 'string', new BackedEnumRule(UserOrderBy::NAME)], | ||
'orderDir' => ['bail', 'string', new BackedEnumRule(OrderDirection::ASCENDING)], | ||
'page' => ['bail', 'integer'], | ||
'perPage' => ['bail', 'integer'], | ||
]; | ||
} | ||
|
||
public function getOrderBy(): ?UserOrderBy | ||
{ | ||
return UserOrderBy::tryFrom($this->input('orderBy')); | ||
} | ||
|
||
public function getOrderDirection(): ?OrderDirection | ||
{ | ||
return OrderDirection::tryFrom($this->input('orderDir')); | ||
} | ||
|
||
public function getPage(): ?int | ||
{ | ||
return is_null($this->input('page')) | ||
? null | ||
: $this->input('page'); | ||
} | ||
|
||
public function getPerPage(): ?int | ||
{ | ||
return is_null($this->input('perPage')) | ||
? null | ||
: $this->input('perPage'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.