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