Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Models/Backup.php
7432 views
1
<?php
2
3
namespace Pterodactyl\Models;
4
5
use Illuminate\Database\Eloquent\SoftDeletes;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
9
/**
10
* @property int $id
11
* @property int $server_id
12
* @property string $uuid
13
* @property bool $is_successful
14
* @property bool $is_locked
15
* @property string $name
16
* @property string[] $ignored_files
17
* @property string $disk
18
* @property string|null $checksum
19
* @property int $bytes
20
* @property string|null $upload_id
21
* @property \Carbon\CarbonImmutable|null $completed_at
22
* @property \Carbon\CarbonImmutable $created_at
23
* @property \Carbon\CarbonImmutable $updated_at
24
* @property \Carbon\CarbonImmutable|null $deleted_at
25
* @property Server $server
26
* @property \Pterodactyl\Models\AuditLog[] $audits
27
*/
28
class Backup extends Model
29
{
30
/** @use HasFactory<\Database\Factories\BackupFactory> */
31
use HasFactory;
32
use SoftDeletes;
33
34
public const RESOURCE_NAME = 'backup';
35
36
public const ADAPTER_WINGS = 'wings';
37
public const ADAPTER_AWS_S3 = 's3';
38
39
protected $table = 'backups';
40
41
protected bool $immutableDates = true;
42
43
protected $casts = [
44
'id' => 'int',
45
'is_successful' => 'bool',
46
'is_locked' => 'bool',
47
'ignored_files' => 'array',
48
'bytes' => 'int',
49
'completed_at' => 'datetime',
50
];
51
52
protected $attributes = [
53
'is_successful' => false,
54
'is_locked' => false,
55
'checksum' => null,
56
'bytes' => 0,
57
'upload_id' => null,
58
];
59
60
protected $guarded = ['id', 'created_at', 'updated_at', 'deleted_at'];
61
62
public static array $validationRules = [
63
'server_id' => 'bail|required|numeric|exists:servers,id',
64
'uuid' => 'required|uuid',
65
'is_successful' => 'boolean',
66
'is_locked' => 'boolean',
67
'name' => 'required|string',
68
'ignored_files' => 'array',
69
'disk' => 'required|string',
70
'checksum' => 'nullable|string',
71
'bytes' => 'numeric',
72
'upload_id' => 'nullable|string',
73
];
74
75
public function server(): BelongsTo
76
{
77
return $this->belongsTo(Server::class);
78
}
79
}
80
81