|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Pterodactyl\Models; |
| 4 | + |
| 5 | +/** |
| 6 | + * @property int $id |
| 7 | + * @property int $server_id |
| 8 | + * @property int $old_node |
| 9 | + * @property int $new_node |
| 10 | + * @property int $old_allocation |
| 11 | + * @property int $new_allocation |
| 12 | + * @property string $old_additional_allocations |
| 13 | + * @property string $new_additional_allocations |
| 14 | + * @property \Carbon\Carbon $created_at |
| 15 | + * @property \Carbon\Carbon $updated_at |
| 16 | + * |
| 17 | + * @property \Pterodactyl\Models\Server $server |
| 18 | + */ |
| 19 | +class ServerTransfer extends Validable |
| 20 | +{ |
| 21 | + /** |
| 22 | + * The resource name for this model when it is transformed into an |
| 23 | + * API representation using fractal. |
| 24 | + */ |
| 25 | + const RESOURCE_NAME = 'server_transfer'; |
| 26 | + |
| 27 | + /** |
| 28 | + * The table associated with the model. |
| 29 | + * |
| 30 | + * @var string |
| 31 | + */ |
| 32 | + protected $table = 'server_transfers'; |
| 33 | + |
| 34 | + /** |
| 35 | + * Fields that are not mass assignable. |
| 36 | + * |
| 37 | + * @var array |
| 38 | + */ |
| 39 | + protected $guarded = ['id', 'created_at', 'updated_at']; |
| 40 | + |
| 41 | + /** |
| 42 | + * Cast values to correct type. |
| 43 | + * |
| 44 | + * @var array |
| 45 | + */ |
| 46 | + protected $casts = [ |
| 47 | + 'server_id' => 'int', |
| 48 | + 'old_node' => 'int', |
| 49 | + 'new_node' => 'int', |
| 50 | + 'old_allocation' => 'int', |
| 51 | + 'new_allocation' => 'int', |
| 52 | + 'old_additional_allocations' => 'string', |
| 53 | + 'new_additional_allocations' => 'string', |
| 54 | + ]; |
| 55 | + |
| 56 | + /** |
| 57 | + * @var array |
| 58 | + */ |
| 59 | + public static $validationRules = [ |
| 60 | + 'server_id' => 'required|numeric|exists:servers,id', |
| 61 | + 'old_node' => 'required|numeric', |
| 62 | + 'new_node' => 'required|numeric', |
| 63 | + 'old_allocation' => 'required|numeric', |
| 64 | + 'new_allocation' => 'required|numeric', |
| 65 | + 'old_additional_allocations' => 'nullable', |
| 66 | + 'new_additional_allocations' => 'nullable', |
| 67 | + ]; |
| 68 | + |
| 69 | + /** |
| 70 | + * Gets the server associated with a subuser. |
| 71 | + * |
| 72 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 73 | + */ |
| 74 | + public function server() |
| 75 | + { |
| 76 | + return $this->belongsTo(Server::class); |
| 77 | + } |
| 78 | +} |
0 commit comments