#23 - collective editing vacation days (#26)

* #23 - wip

* #23 - wip

* #23 - wip

* #23 - wip

* #23 - fix

* #23 - ecs fix

* #23 - fix

* #23 - fix

* #23 - cr fix
This commit is contained in:
Adrian Hopek
2022-01-24 11:28:00 +01:00
committed by GitHub
parent 652587dbf1
commit e147d24365
35 changed files with 1000 additions and 41 deletions

View File

@@ -6,20 +6,24 @@ namespace Toby\Observers;
use Illuminate\Support\Facades\Storage;
use Toby\Helpers\UserAvatarGenerator;
use Toby\Helpers\YearPeriodRetriever;
use Toby\Models\User;
class UserObserver
{
public function __construct(
protected UserAvatarGenerator $generator,
protected YearPeriodRetriever $yearPeriodRetriever,
) {
}
public function created(User $user): void
{
$user->avatar = $this->generator->generateFor($user);
$user->saveAvatar($this->generator->generateFor($user));
$user->save();
$user->vacationLimits()->create([
"year_period_id" => $this->yearPeriodRetriever->current()->id,
]);
}
public function updating(User $user): void