- Add bulk restore + archived-only force delete actions - Add jobs + tests for bulk restore/force delete - Treat restore_run status 'partial' as deletable for hygiene - Update feature tasks checklist
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class RestoreRun extends Model
|
|
{
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'is_dry_run' => 'boolean',
|
|
'requested_items' => 'array',
|
|
'preview' => 'array',
|
|
'results' => 'array',
|
|
'metadata' => 'array',
|
|
'started_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
public function backupSet(): BelongsTo
|
|
{
|
|
return $this->belongsTo(BackupSet::class);
|
|
}
|
|
|
|
public function scopeDeletable($query)
|
|
{
|
|
return $query->whereIn('status', ['completed', 'failed', 'aborted', 'completed_with_errors', 'partial']);
|
|
}
|
|
|
|
public function isDeletable(): bool
|
|
{
|
|
return in_array($this->status, ['completed', 'failed', 'aborted', 'completed_with_errors', 'partial'], true);
|
|
}
|
|
}
|