* #20 - wip * #20 - wip * #20 - fix * #20 - wip * #20 - fix * #20 - fix
This commit is contained in:
@@ -7,7 +7,8 @@ namespace Toby\Infrastructure\Http\Requests;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
use Toby\Domain\EmploymentForm;
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Domain\Enums\Role;
|
||||
|
||||
class UserRequest extends FormRequest
|
||||
{
|
||||
@@ -17,6 +18,7 @@ class UserRequest extends FormRequest
|
||||
"firstName" => ["required", "min:3", "max:80"],
|
||||
"lastName" => ["required", "min:3", "max:80"],
|
||||
"email" => ["required", "email", Rule::unique("users", "email")->ignore($this->user)],
|
||||
"role" => ["required", new Enum(Role::class)],
|
||||
"employmentForm" => ["required", new Enum(EmploymentForm::class)],
|
||||
"employmentDate" => ["required", "date_format:Y-m-d"],
|
||||
];
|
||||
@@ -28,6 +30,7 @@ class UserRequest extends FormRequest
|
||||
"first_name" => $this->get("firstName"),
|
||||
"last_name" => $this->get("lastName"),
|
||||
"email" => $this->get("email"),
|
||||
"role" => $this->get("role"),
|
||||
"employment_form" => $this->get("employmentForm"),
|
||||
"employment_date" => $this->get("employmentDate"),
|
||||
];
|
||||
|
33
app/Infrastructure/Http/Requests/VacationRequestRequest.php
Normal file
33
app/Infrastructure/Http/Requests/VacationRequestRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Infrastructure\Http\Rules\YearPeriodExists;
|
||||
|
||||
class VacationRequestRequest extends FormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
"type" => ["required", new Enum(VacationType::class)],
|
||||
"from" => ["required", "date_format:Y-m-d", new YearPeriodExists()],
|
||||
"to" => ["required", "date_format:Y-m-d", new YearPeriodExists()],
|
||||
"comment" => ["nullable"],
|
||||
];
|
||||
}
|
||||
|
||||
public function data(): array
|
||||
{
|
||||
return [
|
||||
"type" => $this->get("type"),
|
||||
"from" => $this->get("from"),
|
||||
"to" => $this->get("to"),
|
||||
"comment" => $this->get("comment"),
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user