#85 - google calendar improvements (#86)

* google calendar improvements

* fix

* change vacation request name

* #85 - google calendar improvements

* #85 - fix

* #85 - fix

* #85 - fix
This commit is contained in:
Adrian Hopek
2022-03-18 08:11:34 +01:00
committed by GitHub
parent afb1a5e9ff
commit 8c1819aa01
13 changed files with 120 additions and 71 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}";
}
}