toby/app/Infrastructure/Http/Requests/UserRequest.php
Krzysztof Rewak f6d59f8bfb
- directory refactor (#32)
* - directory refactor

* - readme.md update

* Update readme.md

Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl>

* Update readme.md

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* Update readme.md

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* Update readme.md

Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>

* Update readme.md

Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl>
Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
2022-01-26 12:31:26 +01:00

36 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Toby\Infrastructure\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
use Toby\Domain\EmploymentForm;
class UserRequest extends FormRequest
{
public function rules(): array
{
return [
"firstName" => ["required", "min:3", "max:80"],
"lastName" => ["required", "min:3", "max:80"],
"email" => ["required", "email", Rule::unique("users", "email")->ignore($this->user)],
"employmentForm" => ["required", new Enum(EmploymentForm::class)],
"employmentDate" => ["required", "date_format:Y-m-d"],
];
}
public function data(): array
{
return [
"first_name" => $this->get("firstName"),
"last_name" => $this->get("lastName"),
"email" => $this->get("email"),
"employment_form" => $this->get("employmentForm"),
"employment_date" => $this->get("employmentDate"),
];
}
}