mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 15:02:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
*/
|
||||
class Backup extends AbstractModel
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\BackupFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
@ -46,13 +47,18 @@ public static function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function (Backup $backup) {
|
||||
$backup->files()->each(function (BackupFile $file) {
|
||||
static::deleting(function ($backup): void {
|
||||
/** @var Backup $backup */
|
||||
$backup->files()->each(function ($file): void {
|
||||
/** @var BackupFile $file */
|
||||
$file->delete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public static array $statusColors = [
|
||||
BackupStatus::RUNNING => 'success',
|
||||
BackupStatus::FAILED => 'danger',
|
||||
@ -62,31 +68,46 @@ public static function boot(): void
|
||||
public function isCustomInterval(): bool
|
||||
{
|
||||
$intervals = array_keys(config('core.cronjob_intervals'));
|
||||
$intervals = array_filter($intervals, fn ($interval) => $interval !== 'custom');
|
||||
$intervals = array_filter($intervals, fn ($interval): bool => $interval !== 'custom');
|
||||
|
||||
return ! in_array($this->interval, $intervals);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Server, covariant $this>
|
||||
*/
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<StorageProvider, covariant $this>
|
||||
*/
|
||||
public function storage(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StorageProvider::class, 'storage_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Database, covariant $this>
|
||||
*/
|
||||
public function database(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Database::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<BackupFile, covariant $this>
|
||||
*/
|
||||
public function files(): HasMany
|
||||
{
|
||||
return $this->hasMany(BackupFile::class, 'backup_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne<BackupFile, covariant $this>
|
||||
*/
|
||||
public function lastFile(): HasOne
|
||||
{
|
||||
return $this->hasOne(BackupFile::class, 'backup_id')->latest();
|
||||
|
Reference in New Issue
Block a user