2023-09-20 13:42:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2023-09-25 15:41:35 +00:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2023-09-20 13:42:41 +00:00
|
|
|
|
|
|
|
class ServiceApplication extends BaseModel
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
|
2023-09-22 09:23:49 +00:00
|
|
|
public function type()
|
|
|
|
{
|
|
|
|
return 'service';
|
|
|
|
}
|
2023-09-22 10:08:51 +00:00
|
|
|
public function service()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Service::class);
|
|
|
|
}
|
2023-09-22 09:23:49 +00:00
|
|
|
public function persistentStorages()
|
|
|
|
{
|
|
|
|
return $this->morphMany(LocalPersistentVolume::class, 'resource');
|
|
|
|
}
|
2023-09-22 19:31:47 +00:00
|
|
|
public function fileStorages()
|
|
|
|
{
|
|
|
|
return $this->morphMany(LocalFileVolume::class, 'resource');
|
|
|
|
}
|
2023-09-25 10:49:55 +00:00
|
|
|
public function saveFileVolumes()
|
|
|
|
{
|
|
|
|
saveFileVolumesHelper($this);
|
|
|
|
}
|
2023-09-27 10:45:53 +00:00
|
|
|
public function configurationRequired() {
|
|
|
|
$required = false;
|
|
|
|
foreach($this->fileStorages as $fileStorage) {
|
|
|
|
if (!$fileStorage->is_directory && $fileStorage->content == null) {
|
|
|
|
$required = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $required;
|
|
|
|
}
|
2023-09-20 13:42:41 +00:00
|
|
|
}
|