36 lines
923 B
PHP
36 lines
923 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BackupJob extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'backup_jobs';
|
|
|
|
protected $fillable = [
|
|
'policy_id','status','started_at','finished_at',
|
|
'size_bytes','artifact_path','checksum','log_excerpt','error',
|
|
];
|
|
|
|
protected $casts = [
|
|
'policy_id' => 'integer',
|
|
'size_bytes' => 'integer',
|
|
'started_at' => 'datetime',
|
|
'finished_at' => 'datetime',
|
|
];
|
|
|
|
public function policy()
|
|
{
|
|
return $this->belongsTo(BackupPolicy::class, 'policy_id');
|
|
}
|
|
|
|
/* Scopes */
|
|
public function scopeOk($q) { return $q->where('status', 'ok'); }
|
|
public function scopeFailed($q) { return $q->where('status', 'failed'); }
|
|
public function scopeRunning($q) { return $q->where('status', 'running'); }
|
|
}
|