This commit is contained in:
Adrian Hopek
2022-01-24 10:23:08 +01:00
parent 75889a16e6
commit 62fc1e1ca9
14 changed files with 51 additions and 37 deletions

View File

@@ -48,4 +48,4 @@ class YearPeriodRetriever
"link" => route("year-periods.select", $yearPeriod->id),
];
}
}
}

View File

@@ -11,8 +11,9 @@ use Toby\Http\Resources\UserResource;
class HandleInertiaRequests extends Middleware
{
public function __construct(protected YearPeriodRetriever $yearPeriodRetriever)
{
public function __construct(
protected YearPeriodRetriever $yearPeriodRetriever,
) {
}
public function share(Request $request): array

View File

@@ -20,7 +20,6 @@ class VacationLimitRequest extends FormRequest
];
}
public function vacationLimits(): Collection
{
return VacationLimit::query()->find($this->collect("items")->pluck("id"));
@@ -32,7 +31,7 @@ class VacationLimitRequest extends FormRequest
$item["id"] => [
"has_vacation" => $item["hasVacation"],
"days" => $item["days"],
]
],
]);
}
}

View File

@@ -21,7 +21,9 @@ class UserObserver
{
$user->saveAvatar($this->generator->generateFor($user));
$user->vacationLimits()->create(["year_period_id" => $this->yearPeriodRetriever->current()->id]);
$user->vacationLimits()->create([
"year_period_id" => $this->yearPeriodRetriever->current()->id,
]);
}
public function updating(User $user): void

View File

@@ -20,7 +20,9 @@ class YearPeriodObserver
$users = User::all();
foreach ($users as $user) {
$yearPeriod->vacationLimits()->updateOrCreate(["user_id" => $user->id]);
$yearPeriod->vacationLimits()->updateOrCreate([
"user_id" => $user->id,
]);
}
}
}

View File

@@ -11,12 +11,13 @@ use Toby\Helpers\YearPeriodRetriever;
class SelectedYearPeriodScope implements Scope
{
public function __construct(protected YearPeriodRetriever $yearPeriodRetriever)
{
public function __construct(
protected YearPeriodRetriever $yearPeriodRetriever,
) {
}
public function apply(Builder $builder, Model $model): Builder
{
return $builder->where("year_period_id", $this->yearPeriodRetriever->selected()->id);
}
}
}