PayrollPeriodStatus::class, 'closed_at' => 'datetime', ]; } public function closedBy(): BelongsTo { return $this->belongsTo(User::class, 'closed_by_id'); } public function payrolls(): HasMany { return $this->hasMany(Payroll::class); } public function closedAtFormatted(): Attribute { return Attribute::make( get: fn () => $this->closed_at?->translatedFormat('l, d F Y H:i'), ); } public function periodLabel(): Attribute { return Attribute::make( get: fn () => Carbon::create($this->year, $this->month, 1)->translatedFormat('F Y'), ); } public function statusLabel(): Attribute { return Attribute::make( get: fn () => $this->status?->label(), ); } public function isOpen(): bool { return $this->status === PayrollPeriodStatus::OPEN; } #[Scope] public function open(Builder $query): void { $query->where('status', PayrollPeriodStatus::OPEN); } }