toby/app/Domain/Validation/Rules/NoApprovedVacationRequestsInRange.php
Adrian Hopek b161981d5a
#36 - validate vacation request (#47)
* #36 - wip

* #36 - wip

* #36 - wip

* #36 - added some translations

* #36 - fix

* #36 - fix

Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
2022-02-07 12:29:46 +01:00

27 lines
656 B
PHP

<?php
declare(strict_types=1);
namespace Toby\Domain\Validation\Rules;
use Toby\Domain\Enums\VacationRequestState;
use Toby\Eloquent\Models\VacationRequest;
class NoApprovedVacationRequestsInRange implements VacationRequestRule
{
public function check(VacationRequest $vacationRequest): bool
{
return !$vacationRequest
->user
->vacationRequests()
->overlapsWith($vacationRequest)
->states(VacationRequestState::successStates())
->exists();
}
public function errorMessage(): string
{
return __("You have approved vacation request in this range.");
}
}