#20 - wip
This commit is contained in:
		
							
								
								
									
										16
									
								
								app/Helpers/Rules/MinimumOneVacationDayRule.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/Helpers/Rules/MinimumOneVacationDayRule.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| <?php | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| namespace Toby\Helpers\Rules; | ||||
|  | ||||
| use Closure; | ||||
| use Toby\Models\VacationRequest; | ||||
|  | ||||
| class MinimumOneVacationDayRule | ||||
| { | ||||
|     public function check(VacationRequest $vacationRequest, Closure $next) | ||||
|     { | ||||
|         return $next($vacationRequest); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										16
									
								
								app/Helpers/Rules/PendingVacationRequestInSameRange.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/Helpers/Rules/PendingVacationRequestInSameRange.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| <?php | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| namespace Toby\Helpers\Rules; | ||||
|  | ||||
| use Closure; | ||||
| use Toby\Models\VacationRequest; | ||||
|  | ||||
| class PendingVacationRequestInSameRange | ||||
| { | ||||
|     public function check(VacationRequest $vacationRequest, Closure $next) | ||||
|     { | ||||
|         return $next($vacationRequest); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										16
									
								
								app/Helpers/Rules/UsedVacationDaysInSameRange.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/Helpers/Rules/UsedVacationDaysInSameRange.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| <?php | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| namespace Toby\Helpers\Rules; | ||||
|  | ||||
| use Closure; | ||||
| use Toby\Models\VacationRequest; | ||||
|  | ||||
| class UsedVacationDaysInSameRange | ||||
| { | ||||
|     public function check(VacationRequest $vacationRequest, Closure $next) | ||||
|     { | ||||
|         return $next($vacationRequest); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										28
									
								
								app/Helpers/VacationRequestValidator.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								app/Helpers/VacationRequestValidator.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| <?php | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| namespace Toby\Helpers; | ||||
|  | ||||
| use Illuminate\Contracts\Pipeline\Pipeline; | ||||
| use Toby\Models\VacationRequest; | ||||
|  | ||||
| class VacationRequestValidator | ||||
| { | ||||
|     protected array $rules = [ | ||||
|  | ||||
|     ]; | ||||
|  | ||||
|     public function __construct(protected Pipeline $pipeline) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function validate(VacationRequest $vacationRequest): void | ||||
|     { | ||||
|         $this->pipeline | ||||
|             ->send($vacationRequest) | ||||
|             ->through($this->rules) | ||||
|             ->via("check") | ||||
|             ->then(fn(VacationRequest $vacationRequest) => $vacationRequest); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user