Files
fotospiel-app/app/Models/DataExport.php
Codex Agent eed7699549
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled
Implement compliance exports and retention overrides
2026-01-02 20:13:45 +01:00

66 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use App\Enums\DataExportScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class DataExport extends Model
{
use HasFactory;
public const STATUS_PENDING = 'pending';
public const STATUS_PROCESSING = 'processing';
public const STATUS_READY = 'ready';
public const STATUS_FAILED = 'failed';
protected $fillable = [
'user_id',
'tenant_id',
'event_id',
'status',
'scope',
'include_media',
'path',
'size_bytes',
'expires_at',
'error_message',
];
protected $casts = [
'expires_at' => 'datetime',
'include_media' => 'boolean',
'scope' => DataExportScope::class,
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
}
public function isReady(): bool
{
return $this->status === self::STATUS_READY;
}
public function hasExpired(): bool
{
return $this->expires_at !== null && $this->expires_at->isPast();
}
}