2020-04-04 06:40:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
/**
|
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
|
2021-07-11 19:15:39 +00:00
|
|
|
* @property \Pterodactyl\Models\AuditLog[] $audits
|
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
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $table = 'backups';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
protected $immutableDates = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
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',
|
2020-04-04 06:40:20 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $dates = [
|
|
|
|
'completed_at',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2020-04-04 19:26:39 +00:00
|
|
|
* @var array
|
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
|
|
|
/**
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
protected $guarded = ['id', 'created_at', 'updated_at', 'deleted_at'];
|
|
|
|
|
2020-04-04 19:26:39 +00:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public static $validationRules = [
|
|
|
|
'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
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function server()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Server::class);
|
|
|
|
}
|
2021-07-11 19:15:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function audits()
|
|
|
|
{
|
|
|
|
return $this->hasMany(AuditLog::class, 'metadata->backup_uuid', 'uuid')
|
|
|
|
->where('action', 'LIKE', 'server:backup.%');
|
|
|
|
// ->where('metadata->backup_uuid', $this->uuid);
|
|
|
|
}
|
2020-04-04 06:40:20 +00:00
|
|
|
}
|