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