mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
2.x - backups
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* @property string $type
|
||||
@ -46,14 +47,14 @@ public static function boot(): void
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function (Backup $backup) {
|
||||
$backup->files()->delete();
|
||||
$backup->files()->each(function (BackupFile $file) {
|
||||
$file->delete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static array $statusColors = [
|
||||
BackupStatus::READY => 'success',
|
||||
BackupStatus::RUNNING => 'warning',
|
||||
BackupStatus::DELETING => 'warning',
|
||||
BackupStatus::RUNNING => 'success',
|
||||
BackupStatus::FAILED => 'danger',
|
||||
];
|
||||
|
||||
@ -76,4 +77,9 @@ public function files(): HasMany
|
||||
{
|
||||
return $this->hasMany(BackupFile::class, 'backup_id');
|
||||
}
|
||||
|
||||
public function lastFile(): HasOne
|
||||
{
|
||||
return $this->hasOne(BackupFile::class, 'backup_id')->latest();
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ protected static function booted(): void
|
||||
BackupFileStatus::CREATING => 'warning',
|
||||
BackupFileStatus::FAILED => 'danger',
|
||||
BackupFileStatus::DELETING => 'warning',
|
||||
BackupFileStatus::RESTORED => 'warning',
|
||||
BackupFileStatus::RESTORING => 'warning',
|
||||
BackupFileStatus::RESTORED => 'primary',
|
||||
BackupFileStatus::RESTORE_FAILED => 'danger',
|
||||
];
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
* @property array $credentials
|
||||
* @property User $user
|
||||
* @property int $project_id
|
||||
* @property string $image_url
|
||||
*/
|
||||
class StorageProvider extends AbstractModel
|
||||
{
|
||||
@ -61,4 +62,9 @@ public static function getByProjectId(int $projectId): Builder
|
||||
->where('project_id', $projectId)
|
||||
->orWhereNull('project_id');
|
||||
}
|
||||
|
||||
public function getImageUrlAttribute(): string
|
||||
{
|
||||
return url('/static/images/'.$this->provider.'.svg');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user