Files
panel/app/Models/ServerVariable.php

66 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2015-12-08 18:33:33 -05:00
<?php
2016-12-07 22:46:38 +00:00
2024-03-12 22:39:16 -04:00
namespace App\Models;
2015-12-08 18:33:33 -05:00
use App\Contracts\Validatable;
use App\Traits\HasValidation;
2025-09-24 13:34:19 +02:00
use Carbon\CarbonImmutable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $id
* @property int $server_id
* @property int $variable_id
* @property string $variable_value
* @property CarbonImmutable|null $created_at
* @property CarbonImmutable|null $updated_at
* @property EggVariable $variable
* @property Server $server
*/
class ServerVariable extends Model implements Validatable
2015-12-08 18:33:33 -05:00
{
use HasValidation;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
2021-01-23 12:33:34 -08:00
public const RESOURCE_NAME = 'server_variable';
protected $guarded = ['id', 'created_at', 'updated_at'];
/** @var array<array-key, string[]> */
public static array $validationRules = [
'server_id' => ['required', 'int'],
'variable_id' => ['required', 'int'],
'variable_value' => ['string'],
];
2024-03-19 21:08:49 -04:00
protected function casts(): array
{
return [
'server_id' => 'integer',
'variable_id' => 'integer',
'created_at' => 'immutable_datetime',
'updated_at' => 'immutable_datetime',
];
}
2017-08-12 15:32:34 -05:00
/**
* Returns the server this variable is associated with.
2017-08-12 15:32:34 -05:00
*/
public function server(): BelongsTo
2017-08-12 15:32:34 -05:00
{
return $this->belongsTo(Server::class);
2017-08-12 15:32:34 -05:00
}
2017-08-12 15:32:34 -05:00
/**
* Returns information about a given variables parent.
*/
public function variable(): BelongsTo
2017-08-12 15:32:34 -05:00
{
return $this->belongsTo(EggVariable::class, 'variable_id');
2017-08-12 15:32:34 -05:00
}
2015-12-08 18:33:33 -05:00
}