2020-04-03 23:40:20 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2026-02-14 11:21:57 -08:00
|
|
|
use Pterodactyl\Contracts\Models\Identifiable;
|
|
|
|
|
use Pterodactyl\Models\Traits\HasRealtimeIdentifier;
|
2022-10-14 10:59:20 -06:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2024-10-21 19:18:20 -06:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2020-04-03 23:40:20 -07:00
|
|
|
|
|
|
|
|
/**
|
2021-01-27 20:52:11 -08:00
|
|
|
* @property int $id
|
|
|
|
|
* @property int $server_id
|
|
|
|
|
* @property string $uuid
|
|
|
|
|
* @property bool $is_successful
|
2021-05-03 21:26:09 -07:00
|
|
|
* @property bool $is_locked
|
2021-01-27 20:52:11 -08:00
|
|
|
* @property string $name
|
|
|
|
|
* @property string[] $ignored_files
|
|
|
|
|
* @property string $disk
|
|
|
|
|
* @property string|null $checksum
|
|
|
|
|
* @property int $bytes
|
|
|
|
|
* @property string|null $upload_id
|
2020-04-03 23:40:20 -07:00
|
|
|
* @property \Carbon\CarbonImmutable|null $completed_at
|
2021-01-27 20:52:11 -08:00
|
|
|
* @property \Carbon\CarbonImmutable $created_at
|
|
|
|
|
* @property \Carbon\CarbonImmutable $updated_at
|
2020-04-03 23:40:20 -07:00
|
|
|
* @property \Carbon\CarbonImmutable|null $deleted_at
|
2024-10-21 19:18:20 -06:00
|
|
|
* @property Server $server
|
2021-07-11 12:15:39 -07:00
|
|
|
* @property \Pterodactyl\Models\AuditLog[] $audits
|
2020-04-03 23:40:20 -07:00
|
|
|
*/
|
2026-02-14 11:21:57 -08:00
|
|
|
#[Attributes\Identifiable('bkup')]
|
|
|
|
|
class Backup extends Model implements Identifiable
|
2020-04-03 23:40:20 -07:00
|
|
|
{
|
2024-10-21 19:18:20 -06:00
|
|
|
/** @use HasFactory<\Database\Factories\BackupFactory> */
|
|
|
|
|
use HasFactory;
|
2020-04-03 23:40:20 -07:00
|
|
|
use SoftDeletes;
|
2026-02-14 11:21:57 -08:00
|
|
|
use HasRealtimeIdentifier;
|
2020-04-03 23:40:20 -07:00
|
|
|
|
2021-01-23 12:33:34 -08:00
|
|
|
public const RESOURCE_NAME = 'backup';
|
2020-04-04 10:59:25 -07:00
|
|
|
|
2021-01-23 12:33:34 -08:00
|
|
|
public const ADAPTER_WINGS = 'wings';
|
|
|
|
|
public const ADAPTER_AWS_S3 = 's3';
|
2020-04-04 19:54:59 -07:00
|
|
|
|
2020-04-03 23:40:20 -07:00
|
|
|
protected $table = 'backups';
|
|
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
protected bool $immutableDates = true;
|
2020-04-03 23:40:20 -07:00
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'id' => 'int',
|
2020-08-20 21:07:53 -07:00
|
|
|
'is_successful' => 'bool',
|
2021-05-03 21:26:09 -07:00
|
|
|
'is_locked' => 'bool',
|
2020-04-18 23:26:59 -07:00
|
|
|
'ignored_files' => 'array',
|
2020-12-26 11:59:21 -07:00
|
|
|
'bytes' => 'int',
|
2023-02-23 12:30:16 -07:00
|
|
|
'completed_at' => 'datetime',
|
2020-04-03 23:40:20 -07:00
|
|
|
];
|
|
|
|
|
|
2020-04-04 12:26:39 -07:00
|
|
|
protected $attributes = [
|
2021-08-03 20:45:25 -06:00
|
|
|
'is_successful' => false,
|
2021-05-03 21:26:09 -07:00
|
|
|
'is_locked' => false,
|
2020-08-23 18:06:47 -07:00
|
|
|
'checksum' => null,
|
2020-04-04 12:26:39 -07:00
|
|
|
'bytes' => 0,
|
2020-12-26 11:59:21 -07:00
|
|
|
'upload_id' => null,
|
2020-04-04 12:26:39 -07:00
|
|
|
];
|
|
|
|
|
|
2020-12-27 11:34:55 -08:00
|
|
|
protected $guarded = ['id', 'created_at', 'updated_at', 'deleted_at'];
|
|
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
public static array $validationRules = [
|
2020-04-04 12:26:39 -07:00
|
|
|
'server_id' => 'bail|required|numeric|exists:servers,id',
|
|
|
|
|
'uuid' => 'required|uuid',
|
2020-08-20 21:07:53 -07:00
|
|
|
'is_successful' => 'boolean',
|
2021-05-03 21:26:09 -07:00
|
|
|
'is_locked' => 'boolean',
|
2020-04-04 12:30:29 -07:00
|
|
|
'name' => 'required|string',
|
2020-04-18 23:26:59 -07:00
|
|
|
'ignored_files' => 'array',
|
2020-04-04 12:26:39 -07:00
|
|
|
'disk' => 'required|string',
|
2020-08-23 18:06:47 -07:00
|
|
|
'checksum' => 'nullable|string',
|
2020-04-04 12:26:39 -07:00
|
|
|
'bytes' => 'numeric',
|
2020-12-27 11:34:55 -08:00
|
|
|
'upload_id' => 'nullable|string',
|
2020-04-04 12:26:39 -07:00
|
|
|
];
|
2020-04-04 10:59:25 -07:00
|
|
|
|
2025-12-20 15:55:13 -08:00
|
|
|
/**
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this>
|
|
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function server(): BelongsTo
|
2020-04-04 10:59:25 -07:00
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Server::class);
|
|
|
|
|
}
|
2020-04-03 23:40:20 -07:00
|
|
|
}
|