* wip * fix * wip * #63 - permissions Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
		
			
				
	
	
		
			27 lines
		
	
	
		
			670 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			670 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| namespace Toby\Domain\Validation\Rules;
 | |
| 
 | |
| use Toby\Domain\VacationRequestStatesRetriever;
 | |
| use Toby\Eloquent\Models\VacationRequest;
 | |
| 
 | |
| class NoApprovedVacationRequestsInRange implements VacationRequestRule
 | |
| {
 | |
|     public function check(VacationRequest $vacationRequest): bool
 | |
|     {
 | |
|         return !$vacationRequest
 | |
|             ->user
 | |
|             ->vacationRequests()
 | |
|             ->overlapsWith($vacationRequest)
 | |
|             ->states(VacationRequestStatesRetriever::successStates())
 | |
|             ->exists();
 | |
|     }
 | |
| 
 | |
|     public function errorMessage(): string
 | |
|     {
 | |
|         return __("You have approved vacation request in this range.");
 | |
|     }
 | |
| }
 |