mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00

* Fix these * Update phpstan * Transform these into their identifiers instead * Fix custom rule * License is wrong * Update these * Pint fixes * Fix this * Consolidate these * Never supported PHP 7 * Better evaluation * Fixes * Don’t need ignore * Replace trait with service * Subusers are simply the many to many relationship between Servers and Users * Adjust to remove ignores * Use new query builder instead! * wip * Update composer * Quick fixes * Use realtime facade * Small fixes * Convert to static to avoid new * Update to statics * Don’t modify protected properties directly * Run pint * Change to correct method * Give up and use the facade * Make sure this route is available * Filament hasn’t been loaded yet * This can be readonly * Typehint * These are no longer used * Quick fixes * Need doc block help * Always true * We use caddy with docker * Pint * Fix phpstan issues * Remove unused import --------- Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com>
92 lines
2.5 KiB
PHP
92 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Eloquent\BackupQueryBuilder;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $server_id
|
|
* @property string $uuid
|
|
* @property bool $is_successful
|
|
* @property bool $is_locked
|
|
* @property string $name
|
|
* @property string[] $ignored_files
|
|
* @property string $disk
|
|
* @property string|null $checksum
|
|
* @property int $bytes
|
|
* @property string|null $upload_id
|
|
* @property \Carbon\CarbonImmutable|null $completed_at
|
|
* @property \Carbon\CarbonImmutable $created_at
|
|
* @property \Carbon\CarbonImmutable $updated_at
|
|
* @property \Carbon\CarbonImmutable|null $deleted_at
|
|
* @property \App\Models\Server $server
|
|
* @property \App\Models\AuditLog[] $audits
|
|
*/
|
|
class Backup extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
public const RESOURCE_NAME = 'backup';
|
|
|
|
public const ADAPTER_DAEMON = 'wings';
|
|
|
|
public const ADAPTER_AWS_S3 = 's3';
|
|
|
|
protected $table = 'backups';
|
|
|
|
protected $attributes = [
|
|
'is_successful' => false,
|
|
'is_locked' => false,
|
|
'checksum' => null,
|
|
'bytes' => 0,
|
|
'upload_id' => null,
|
|
];
|
|
|
|
protected $guarded = ['id', 'created_at', 'updated_at', 'deleted_at'];
|
|
|
|
public static array $validationRules = [
|
|
'server_id' => 'bail|required|numeric|exists:servers,id',
|
|
'uuid' => 'required|uuid',
|
|
'is_successful' => 'boolean',
|
|
'is_locked' => 'boolean',
|
|
'name' => 'required|string',
|
|
'ignored_files' => 'array',
|
|
'disk' => 'required|string',
|
|
'checksum' => 'nullable|string',
|
|
'bytes' => 'numeric',
|
|
'upload_id' => 'nullable|string',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'id' => 'int',
|
|
'is_successful' => 'bool',
|
|
'is_locked' => 'bool',
|
|
'ignored_files' => 'array',
|
|
'bytes' => 'int',
|
|
'completed_at' => 'immutable_datetime',
|
|
'created_at' => 'immutable_datetime',
|
|
'updated_at' => 'immutable_datetime',
|
|
'deleted_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
|
|
public function server(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Server::class);
|
|
}
|
|
|
|
/**
|
|
* @param \Illuminate\Database\Query\Builder $query
|
|
* @return BackupQueryBuilder<\Illuminate\Database\Eloquent\Model>
|
|
*/
|
|
public function newEloquentBuilder($query): BackupQueryBuilder
|
|
{
|
|
return new BackupQueryBuilder($query);
|
|
}
|
|
}
|