#85 - google calendar improvements

This commit is contained in:
Adrian Hopek
2022-03-17 12:59:42 +01:00
parent afb1a5e9ff
commit 88d3ac028d
11 changed files with 118 additions and 68 deletions

View File

@@ -1,28 +0,0 @@
<?php
declare(strict_types=1);
namespace Toby\Eloquent\Observers;
use Illuminate\Contracts\Auth\Factory as Auth;
use Illuminate\Contracts\Events\Dispatcher;
use Toby\Eloquent\Models\VacationRequest;
class VacationRequestObserver
{
public function __construct(
protected Auth $auth,
protected Dispatcher $dispatcher,
) {}
public function creating(VacationRequest $vacationRequest): void
{
$year = $vacationRequest->from->year;
$vacationRequestNumber = $vacationRequest->user->vacationRequests()
->whereYear("from", $year)
->count() + 1;
$vacationRequest->name = "{$vacationRequestNumber}/${year}";
}
}