<?php
 namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class TicketDepartmentCustomField extends Model { use HasFactory; protected $fillable = [ 'ticket_department_id', 'name', 'type', 'required', 'options', 'sort_order', ]; protected $casts = [ 'required' => 'boolean', 'options' => 'array', 'sort_order' => 'integer', ]; public function ticketDepartment(): BelongsTo { return $this->belongsTo(TicketDepartment::class); } public function scopeOrdered($query) { return $query->orderBy('sort_order'); } public static function getFieldTypes(): array { return [ 'text' => 'Metin', 'textarea' => 'Çoklu Satır Metin', 'select' => 'Seçim Listesi', 'checkbox' => 'Onay Kutusu', 'radio' => 'Radyo Buton', 'email' => 'E-posta', 'number' => 'Sayı', 'date' => 'Tarih', ]; } public function needsOptions(): bool { return in_array($this->type, ['select', 'radio']); } } 