<?php
 namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class DataRequest extends Model { use HasFactory; protected $fillable = [ 'client_id', 'type', 'status', 'reason', 'file_path', 'completed_at', 'admin_notes', ]; protected $casts = [ 'completed_at' => 'datetime', ]; const TYPE_EXPORT = 'export'; const TYPE_DELETION = 'deletion'; const TYPES = [ self::TYPE_EXPORT, self::TYPE_DELETION, ]; const STATUS_PENDING = 'pending'; const STATUS_PROCESSING = 'processing'; const STATUS_COMPLETED = 'completed'; const STATUS_REJECTED = 'rejected'; const STATUSES = [ self::STATUS_PENDING, self::STATUS_PROCESSING, self::STATUS_COMPLETED, self::STATUS_REJECTED, ]; public function client(): BelongsTo { return $this->belongsTo(Client::class); } public function scopePending($query) { return $query->where('status', self::STATUS_PENDING); } public function scopeByType($query, string $type) { return $query->where('type', $type); } } 