 e3178ba6f0
			
		
	
	
		e3178ba6f0
		
			
		
	
	
	
	
		
			
			This allows the UI to correctly show failed backups to the user and require them to manually delete those backups, rather than them mysteriously disappearing. We can also hook into this later to send a notification to the user when the backup fails.
		
			
				
	
	
		
			91 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Pterodactyl\Models;
 | |
| 
 | |
| use Illuminate\Database\Eloquent\SoftDeletes;
 | |
| 
 | |
| /**
 | |
|  * @property int $id
 | |
|  * @property int $server_id
 | |
|  * @property int $uuid
 | |
|  * @property bool $is_successful
 | |
|  * @property string $name
 | |
|  * @property string[] $ignored_files
 | |
|  * @property string $disk
 | |
|  * @property string|null $sha256_hash
 | |
|  * @property int $bytes
 | |
|  * @property \Carbon\CarbonImmutable|null $completed_at
 | |
|  * @property \Carbon\CarbonImmutable $created_at
 | |
|  * @property \Carbon\CarbonImmutable $updated_at
 | |
|  * @property \Carbon\CarbonImmutable|null $deleted_at
 | |
|  *
 | |
|  * @property \Pterodactyl\Models\Server $server
 | |
|  */
 | |
| class Backup extends Model
 | |
| {
 | |
|     use SoftDeletes;
 | |
| 
 | |
|     const RESOURCE_NAME = 'backup';
 | |
| 
 | |
|     const ADAPTER_WINGS = 'wings';
 | |
|     const ADAPTER_AWS_S3 = 's3';
 | |
| 
 | |
|     /**
 | |
|      * @var string
 | |
|      */
 | |
|     protected $table = 'backups';
 | |
| 
 | |
|     /**
 | |
|      * @var bool
 | |
|      */
 | |
|     protected $immutableDates = true;
 | |
| 
 | |
|     /**
 | |
|      * @var array
 | |
|      */
 | |
|     protected $casts = [
 | |
|         'id' => 'int',
 | |
|         'is_successful' => 'bool',
 | |
|         'bytes' => 'int',
 | |
|         'ignored_files' => 'array',
 | |
|     ];
 | |
| 
 | |
|     /**
 | |
|      * @var array
 | |
|      */
 | |
|     protected $dates = [
 | |
|         'completed_at',
 | |
|     ];
 | |
| 
 | |
|     /**
 | |
|      * @var array
 | |
|      */
 | |
|     protected $attributes = [
 | |
|         'is_successful' => true,
 | |
|         'sha256_hash' => null,
 | |
|         'bytes' => 0,
 | |
|     ];
 | |
| 
 | |
|     /**
 | |
|      * @var array
 | |
|      */
 | |
|     public static $validationRules = [
 | |
|         'server_id' => 'bail|required|numeric|exists:servers,id',
 | |
|         'uuid' => 'required|uuid',
 | |
|         'is_successful' => 'boolean',
 | |
|         'name' => 'required|string',
 | |
|         'ignored_files' => 'array',
 | |
|         'disk' => 'required|string',
 | |
|         'sha256_hash' => 'nullable|string',
 | |
|         'bytes' => 'numeric',
 | |
|     ];
 | |
| 
 | |
|     /**
 | |
|      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
 | |
|      */
 | |
|     public function server()
 | |
|     {
 | |
|         return $this->belongsTo(Server::class);
 | |
|     }
 | |
| }
 |