'datetime', 'status' => PayrollPeriodStatus::class, ]; } // 3. Scope (grouped by column, then alphabetical) // Column Group: status #[Scope] protected function closed(Builder $query): void { $query->where('status', PayrollPeriodStatus::CLOSED); } #[Scope] protected function open(Builder $query): void { $query->where('status', PayrollPeriodStatus::OPEN); } // 4. Attribute 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(), ); } // 5. Other Methods public function isOpen(): bool { return $this->status === PayrollPeriodStatus::OPEN; } // 6. Relation public function closedBy(): BelongsTo { return $this->belongsTo(User::class, 'closed_by_id')->withTrashed(); } public function payrolls(): HasMany { return $this->hasMany(Payroll::class); } }