'integer', 'other_cost' => 'integer', 'sewing_cost' => 'integer', 'status' => CuttingStatus::class, 'total_material_cost' => 'integer', ]; } // 3. Scope (grouped by column, then alphabetical) // Column Group: status #[Scope] protected function completed(Builder $query): void { $query->where('status', CuttingStatus::COMPLETED); } #[Scope] protected function inProgress(Builder $query): void { $query->where('status', CuttingStatus::IN_PROGRESS); } // 4. Attribute public function createdAtFormatted(): Attribute { return Attribute::make( get: fn () => $this->created_at?->translatedFormat('l, d F Y H:i'), ); } public function statusLabel(): Attribute { return Attribute::make( get: fn () => $this->status->label(), ); } // 5. Other Methods public static function mediaModuleName(): string { return 'cutting'; } public function registerMediaCollections(): void { $this->addMediaCollection('images'); } public function ensureEditable(): void { if (! $this->status->isEditable()) { throw ValidationException::withMessages([ 'status' => 'Proses cutting tidak dapat diubah.', ]); } } // 6. Relation public function createdBy(): BelongsTo { return $this->belongsTo(User::class, 'created_by_id')->withTrashed(); } public function materials(): HasMany { return $this->hasMany(CuttingMaterial::class); } public function combinations(): HasMany { return $this->hasMany(CuttingMaterialCombination::class); } public function results(): HasMany { return $this->hasMany(CuttingResult::class); } public function submittedBy(): BelongsTo { return $this->belongsTo(User::class, 'submitted_by_id')->withTrashed(); } }