
* fix css focuses * #90 - wip * #90 - fix to generate PDF * #90 - wip * #90 - wip * #90 - wip * #90 - wip * #90 - fix to calendar * #90 - wip * #90 - fix * #90 - fix lint * #90 - fix * Apply suggestions from code review Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * #90 - cr fixes * #90 - fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Toby\Infrastructure\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Carbon;
|
|
use Inertia\Response;
|
|
use Toby\Domain\CalendarGenerator;
|
|
use Toby\Domain\Enums\Month;
|
|
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
|
use Toby\Eloquent\Models\User;
|
|
use Toby\Infrastructure\Http\Resources\SimpleUserResource;
|
|
|
|
class VacationCalendarController extends Controller
|
|
{
|
|
public function index(
|
|
Request $request,
|
|
YearPeriodRetriever $yearPeriodRetriever,
|
|
CalendarGenerator $calendarGenerator,
|
|
?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)
|
|
->orderByProfileField("last_name")
|
|
->orderByProfileField("first_name")
|
|
->get();
|
|
|
|
$users->prepend($currentUser);
|
|
|
|
$calendar = $calendarGenerator->generate($carbonMonth);
|
|
|
|
return inertia("Calendar", [
|
|
"calendar" => $calendar,
|
|
"current" => Month::current(),
|
|
"selected" => $month->value,
|
|
"users" => SimpleUserResource::collection($users),
|
|
"can" => [
|
|
"generateTimesheet" => $request->user()->can("generateTimesheet"),
|
|
],
|
|
]);
|
|
}
|
|
}
|