$server->id, ]); }); } protected $fillable = [ 'name', 'ip', 'user', 'port', 'team_id', 'private_key_id', 'extra_attributes', ]; public $casts = [ 'extra_attributes' => SchemalessAttributes::class, ]; public function scopeWithExtraAttributes(): Builder { return $this->extra_attributes->modelScope(); } public function standaloneDockers() { return $this->hasMany(StandaloneDocker::class); } public function swarmDockers() { return $this->hasMany(SwarmDocker::class); } public function privateKey() { return $this->belongsTo(PrivateKey::class); } public function settings() { return $this->hasOne(ServerSetting::class); } static public function ownedByCurrentTeam() { return Server::whereTeamId(session('currentTeam')->id); } static public function validated() { return Server::ownedByCurrentTeam()->whereRelation('settings', 'is_validated', true); } static public function destinationsByServer(string $server_id) { $server = Server::ownedByCurrentTeam()->get()->where('id', $server_id)->firstOrFail(); $standaloneDocker = collect($server->standaloneDockers->all()); $swarmDocker = collect($server->swarmDockers->all()); return $standaloneDocker->concat($swarmDocker); } }