*/ protected $fillable = [ 'user_id', 'requester_username', 'requester_email', 'type', 'status', 'request_payload', 'response_payload', 'notes', 'admin_notes', 'export_disk', 'export_path', 'export_expires_at', 'processed_by', 'completed_at', ]; /** * @return array */ protected function casts(): array { return [ 'request_payload' => 'array', 'response_payload' => 'array', 'export_expires_at' => 'datetime', 'completed_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; } /** * @return BelongsTo */ public function user(): BelongsTo { return $this->belongsTo(User::class)->withTrashed(); } /** * @return BelongsTo */ public function processor(): BelongsTo { return $this->belongsTo(User::class, 'processed_by')->withTrashed(); } /** * @return HasMany */ public function auditLogs(): HasMany { return $this->hasMany(GdprAuditLog::class)->latest(); } /** * @param Builder $query * @return Builder */ public function scopeOpen(Builder $query): Builder { return $query->whereIn('status', [self::STATUS_PENDING, self::STATUS_PROCESSING]); } public function isDownloadableExport(): bool { $expiresAt = $this->export_expires_at; return $this->type === self::TYPE_EXPORT && $this->status === self::STATUS_COMPLETED && $this->export_path !== null && ($expiresAt === null || Carbon::parse($expiresAt)->isFuture()); } }