lasthourcloud/app/Models/ServiceApplication.php
Andras Bacsai 199881c596 fixes
2023-09-28 09:54:21 +02:00

44 lines
967 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\Cache;
class ServiceApplication extends BaseModel
{
use HasFactory;
protected $guarded = [];
public function type()
{
return 'service';
}
public function service()
{
return $this->belongsTo(Service::class);
}
public function persistentStorages()
{
return $this->morphMany(LocalPersistentVolume::class, 'resource');
}
public function fileStorages()
{
return $this->morphMany(LocalFileVolume::class, 'resource');
}
public function fqdns(): Attribute
{
return Attribute::make(
get: fn () => is_null($this->fqdn)
? []
: explode(',', $this->fqdn),
);
}
public function saveFileVolumes()
{
saveFileVolumesHelper($this);
}
}