PayrollPeriodStatus::class, 'year' => 'integer', 'month' => 'integer', 'closed_at' => 'datetime', ]; } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logAll() ->logOnlyDirty() ->dontLogEmptyChanges(); } protected function formattedClosedAt(): Attribute { return Attribute::make( get: fn () => $this->closed_at?->translatedFormat('l, d F Y H:i'), ); } protected function monthName(): Attribute { return Attribute::make( get: fn () => $this->month ? Carbon::create()->month($this->month)->translatedFormat('F') : null, ); } protected function statusLabel(): Attribute { return Attribute::make( get: fn () => $this->status->label(), ); } #[Scope] protected function closed(Builder $query): void { $query->where('status', PayrollPeriodStatus::CLOSED); } #[Scope] protected function open(Builder $query): void { $query->where('status', PayrollPeriodStatus::OPEN); } public function closedBy(): BelongsTo { return $this->belongsTo(User::class, 'closed_by_id'); } public function payrolls(): HasMany { return $this->hasMany(Payroll::class); } }