* #40 - wip * #40 - generate pdf * #40 - fix * Update resources/js/Pages/VacationRequest/Show.vue Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * #40 - fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace Toby\Infrastructure\Http\Requests;
 | 
						|
 | 
						|
use Illuminate\Foundation\Http\FormRequest;
 | 
						|
use Illuminate\Support\Carbon;
 | 
						|
use Illuminate\Validation\Rules\Enum;
 | 
						|
use Toby\Domain\Enums\VacationType;
 | 
						|
use Toby\Eloquent\Models\YearPeriod;
 | 
						|
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
 | 
						|
    {
 | 
						|
        $from = $this->get("from");
 | 
						|
 | 
						|
        return [
 | 
						|
            "type" => $this->get("type"),
 | 
						|
            "from" => $from,
 | 
						|
            "to" => $this->get("to"),
 | 
						|
            "year_period_id" => YearPeriod::findByYear(Carbon::create($from)->year)->id,
 | 
						|
            "comment" => $this->get("comment"),
 | 
						|
        ];
 | 
						|
    }
 | 
						|
}
 |