$application->id, ]); }); } protected $fillable = [ 'name', 'description', 'git_repository', 'git_branch', 'build_pack', 'environment_id', 'destination_id', 'destination_type', 'source_id', 'source_type', 'ports_mappings', 'ports_exposes', ]; public function environment() { return $this->belongsTo(Environment::class); } public function settings() { return $this->hasOne(ApplicationSetting::class); } public function destination() { return $this->morphTo(); } public function source() { return $this->morphTo(); } public function persistentStorages() { return $this->morphMany(LocalPersistentVolume::class, 'resource'); } public function portsMappingsArray(): Attribute { return Attribute::make( get: fn () => is_null($this->ports_mappings) ? [] : explode(',', $this->ports_mappings) ); } public function portsExposesArray(): Attribute { return Attribute::make( get: fn () => is_null($this->ports_exposes) ? [] : explode(',', $this->ports_exposes) ); } public function deployments() { return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '!=', null)->orderBy('created_at', 'desc')->get(); } public function get_deployment(string $deployment_uuid) { return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '=', $deployment_uuid)->first(); } }