This commit is contained in:
Adrian Hopek
2022-01-24 10:19:26 +01:00
parent b4c6cfe612
commit 75889a16e6
12 changed files with 223 additions and 24 deletions

View File

@@ -6,20 +6,22 @@ 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