#28 - holidays management

This commit is contained in:
Adrian Hopek
2022-01-24 14:03:39 +01:00
parent 6854c7a9f8
commit 29d81030ac
20 changed files with 792 additions and 9 deletions

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Toby\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Carbon;
use Toby\Models\YearPeriod;
use Toby\Rules\YearPeriodExists;
class HolidayRequest extends FormRequest
{
public function rules(): array
{
return [
"name" => ["required", "min:3", "max:150"],
"date" => ["required", "date", new YearPeriodExists()],
];
}
public function data(): array
{
$date = $this->get("date");
return [
"name" => $this->get("name"),
"date" => $date,
"year_period_id" => YearPeriod::findByYear(Carbon::create($date)->year)->id,
];
}
}