You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
53 lines
1.0 KiB
53 lines
1.0 KiB
<?php |
|
|
|
namespace App\Models; |
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
class Server extends Model |
|
{ |
|
protected $fillable = [ |
|
"uuid", |
|
'name', |
|
"container", |
|
"start", |
|
"end", |
|
"service_id", |
|
"user_id", |
|
"status_id", |
|
]; |
|
|
|
public function jsonSerialize(): mixed |
|
{ |
|
return [ |
|
"uuid" => $this->uuid, |
|
'name' => $this->name, |
|
"start" => $this->start, |
|
"end" => $this->end, |
|
"service" => $this->service, |
|
"user" => $this->user, |
|
"status" => $this->status, |
|
"ports" => $this->exposedPorts()->pluck("number"), |
|
]; |
|
} |
|
|
|
public function exposedPorts() |
|
{ |
|
return $this->belongsToMany(ExposedPort::class); |
|
} |
|
|
|
public function service() |
|
{ |
|
return $this->belongsTo(Service::class); |
|
} |
|
|
|
public function status() |
|
{ |
|
return $this->belongsTo(Status::class); |
|
} |
|
|
|
public function user() |
|
{ |
|
return $this->belongsTo(User::class); |
|
} |
|
}
|
|
|