wip
This commit is contained in:
parent
fe41fd1cc5
commit
fb15811b16
@ -21,7 +21,7 @@ class UserVacationStatsRetriever
|
||||
{
|
||||
return $user
|
||||
->vacations()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query) => $query
|
||||
@ -37,7 +37,7 @@ class UserVacationStatsRetriever
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query) => $query
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereIn("type", $this->getLimitableVacationTypes())
|
||||
->states(VacationRequestStatesRetriever::successStates()),
|
||||
)
|
||||
@ -50,7 +50,7 @@ class UserVacationStatsRetriever
|
||||
{
|
||||
return $user
|
||||
->vacations()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query) => $query
|
||||
@ -64,7 +64,7 @@ class UserVacationStatsRetriever
|
||||
{
|
||||
return $user
|
||||
->vacations()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query) => $query
|
||||
@ -86,7 +86,7 @@ class UserVacationStatsRetriever
|
||||
public function getVacationDaysLimit(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
$limit = $user->vacationLimits()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->first()
|
||||
?->days;
|
||||
|
||||
|
@ -41,13 +41,16 @@ class DoesNotExceedLimitRule implements VacationRequestRule
|
||||
|
||||
protected function getUserVacationLimit(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
return $user->vacationLimits()->where("year_period_id", $yearPeriod->id)->first()->days ?? 0;
|
||||
return $user->vacationLimits()
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->first()
|
||||
->days ?? 0;
|
||||
}
|
||||
|
||||
protected function getVacationDaysWithLimit(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
return $user->vacations()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query) => $query
|
||||
|
@ -91,7 +91,7 @@ class User extends Authenticatable
|
||||
public function hasVacationLimit(YearPeriod $yearPeriod): bool
|
||||
{
|
||||
return $this->vacationLimits()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereNotNull("days")
|
||||
->exists();
|
||||
}
|
||||
@ -113,7 +113,7 @@ class User extends Authenticatable
|
||||
return $query->whereRelation(
|
||||
"vacationlimits",
|
||||
fn(Builder $query) => $query
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereNotNull("days"),
|
||||
);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class CalculateUserUnavailableDaysController extends Controller
|
||||
|
||||
$holidays = $yearPeriod->holidays()->pluck("date");
|
||||
$vacationDays = $user->vacations()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query) => $query->noStates(VacationRequestStatesRetriever::failedStates()),
|
||||
|
@ -40,26 +40,26 @@ class VacationRequestController extends Controller
|
||||
$vacationRequests = $request->user()
|
||||
->vacationRequests()
|
||||
->with("vacations")
|
||||
->where("year_period_id", $yearPeriodRetriever->selected()->id)
|
||||
->whereBelongsTo($yearPeriodRetriever->selected())
|
||||
->latest()
|
||||
->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user()))
|
||||
->paginate();
|
||||
|
||||
$pending = $request->user()
|
||||
->vacationRequests()
|
||||
->where("year_period_id", $yearPeriodRetriever->selected()->id)
|
||||
->whereBelongsTo($yearPeriodRetriever->selected())
|
||||
->states(VacationRequestStatesRetriever::pendingStates())
|
||||
->count();
|
||||
|
||||
$success = $request->user()
|
||||
->vacationRequests()
|
||||
->where("year_period_id", $yearPeriodRetriever->selected()->id)
|
||||
->whereBelongsTo($yearPeriodRetriever->selected())
|
||||
->states(VacationRequestStatesRetriever::successStates())
|
||||
->count();
|
||||
|
||||
$failed = $request->user()
|
||||
->vacationRequests()
|
||||
->where("year_period_id", $yearPeriodRetriever->selected()->id)
|
||||
->whereBelongsTo($yearPeriodRetriever->selected())
|
||||
->states(VacationRequestStatesRetriever::failedStates())
|
||||
->count();
|
||||
|
||||
@ -91,7 +91,7 @@ class VacationRequestController extends Controller
|
||||
|
||||
$vacationRequests = VacationRequest::query()
|
||||
->with(["user", "vacations"])
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->when($user !== null, fn(Builder $query) => $query->where("user_id", $user))
|
||||
->when(
|
||||
$status !== null,
|
||||
@ -156,7 +156,7 @@ class VacationRequestController extends Controller
|
||||
return $pdf->stream();
|
||||
}
|
||||
|
||||
public function create(Request $request, YearPeriodRetriever $yearPeriodRetriever): Response
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
$users = User::query()
|
||||
->orderBy("last_name")
|
||||
|
Loading…
x
Reference in New Issue
Block a user