lasthourcloud/app/Models/SwarmDocker.php

61 lines
1.4 KiB
PHP
Raw Normal View History

2023-03-27 12:31:42 +00:00
<?php
namespace App\Models;
class SwarmDocker extends BaseModel
{
2023-11-28 14:49:24 +00:00
protected $guarded = [];
2023-03-27 12:31:42 +00:00
public function applications()
{
return $this->morphMany(Application::class, 'destination');
}
2023-11-28 14:49:24 +00:00
public function postgresqls()
{
return $this->morphMany(StandalonePostgresql::class, 'destination');
}
public function redis()
{
return $this->morphMany(StandaloneRedis::class, 'destination');
}
public function mongodbs()
{
return $this->morphMany(StandaloneMongodb::class, 'destination');
}
public function mysqls()
{
return $this->morphMany(StandaloneMysql::class, 'destination');
}
public function mariadbs()
{
return $this->morphMany(StandaloneMariadb::class, 'destination');
}
2023-05-02 10:47:52 +00:00
public function server()
{
return $this->belongsTo(Server::class);
}
2023-11-28 14:49:24 +00:00
public function services()
{
return $this->morphMany(Service::class, 'destination');
}
public function databases()
{
$postgresqls = $this->postgresqls;
$redis = $this->redis;
$mongodbs = $this->mongodbs;
$mysqls = $this->mysqls;
$mariadbs = $this->mariadbs;
return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs);
}
public function attachedTo()
{
return $this->applications?->count() > 0 || $this->databases()->count() > 0;
}
2023-03-27 12:31:42 +00:00
}