*/ use HasFactory; /** * Get the team that owns the period. * * @return BelongsTo */ public function team(): BelongsTo { return $this->belongsTo(Team::class); } /** * Get the service entries for the period. * * @return HasMany */ public function serviceEntries(): HasMany { return $this->hasMany(ServiceEntry::class); } /** * Get the medication expense rows for the period. * * @return HasMany */ public function medicationExpenseRows(): HasMany { return $this->hasMany(MedicationExpenseRow::class); } /** * Determine whether the period can still be edited. */ public function isEditable(): bool { return $this->status === ReportPeriodStatus::Draft; } /** * Get a human-readable label for the period. */ public function label(): string { return sprintf('%s %s', $this->monthName(), $this->year); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'year' => 'integer', 'month' => 'integer', 'status' => ReportPeriodStatus::class, ]; } /** * Get the localized month name. */ protected function monthName(): string { return match ($this->month) { 1 => 'Январь', 2 => 'Февраль', 3 => 'Март', 4 => 'Апрель', 5 => 'Май', 6 => 'Июнь', 7 => 'Июль', 8 => 'Август', 9 => 'Сентябрь', 10 => 'Октябрь', 11 => 'Ноябрь', 12 => 'Декабрь', default => (string) $this->month, }; } }