* - polishing calendar * wip * wip * #74 - wip * #74 - wip * #74 - wip * #74 - fix icons Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
This commit is contained in:
@@ -44,6 +44,7 @@ class CalendarGenerator
|
||||
"isWeekend" => $day->isWeekend(),
|
||||
"isHoliday" => $holidays->contains($day),
|
||||
"vacations" => $vacationsForDay->pluck("user_id"),
|
||||
"vacationTypes" => $vacationsForDay->pluck("vacationRequest.type", "user_id"),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,6 +56,7 @@ class CalendarGenerator
|
||||
return Vacation::query()
|
||||
->whereBetween("date", [$period->start, $period->end])
|
||||
->whereRelation("vacationRequest", fn(Builder $query) => $query->states(VacationRequestStatesRetriever::successStates()))
|
||||
->with("vacationRequest")
|
||||
->get()
|
||||
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
||||
}
|
||||
|
@@ -22,20 +22,25 @@ class VacationCalendarController extends Controller
|
||||
?string $month = null,
|
||||
): Response {
|
||||
$month = Month::fromNameOrCurrent((string)$month);
|
||||
$currentUser = $request->user();
|
||||
|
||||
$yearPeriod = $yearPeriodRetriever->selected();
|
||||
$carbonMonth = Carbon::create($yearPeriod->year, $month->toCarbonNumber());
|
||||
|
||||
$users = User::query()
|
||||
->where("id", "!=", $currentUser->id)
|
||||
->orderBy("last_name")
|
||||
->orderBy("first_name")
|
||||
->get();
|
||||
|
||||
$users->prepend($currentUser);
|
||||
|
||||
$calendar = $calendarGenerator->generate($carbonMonth);
|
||||
|
||||
return inertia("Calendar", [
|
||||
"calendar" => $calendar,
|
||||
"currentMonth" => $month->value,
|
||||
"current" => Month::current(),
|
||||
"selected" => $month->value,
|
||||
"users" => UserResource::collection($users),
|
||||
"can" => [
|
||||
"generateTimesheet" => $request->user()->can("generateTimesheet"),
|
||||
|
@@ -16,7 +16,7 @@ class VacationRequestResource extends JsonResource
|
||||
"id" => $this->id,
|
||||
"name" => $this->name,
|
||||
"user" => new UserResource($this->user),
|
||||
"type" => $this->type->label(),
|
||||
"type" => $this->type,
|
||||
"state" => $this->state,
|
||||
"from" => $this->from->toDisplayString(),
|
||||
"to" => $this->to->toDisplayString(),
|
||||
|
Reference in New Issue
Block a user