44 lines
904 B
PHP
44 lines
904 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
class ServiceReplica extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'cpu_limit' => 'decimal:3',
|
|
'config' => 'array',
|
|
];
|
|
}
|
|
|
|
public function service(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Service::class);
|
|
}
|
|
|
|
public function server(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Server::class);
|
|
}
|
|
|
|
public function operation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Operation::class);
|
|
}
|
|
|
|
public function operations(): MorphMany
|
|
{
|
|
return $this->morphMany(Operation::class, 'target');
|
|
}
|
|
}
|