Save storage on initial creation

This commit is contained in:
Andras Bacsai
2024-02-14 10:21:53 +01:00
parent 93e4fc2f32
commit 4b08abc144

View File

@@ -10,12 +10,19 @@ class LocalFileVolume extends BaseModel
use HasFactory; use HasFactory;
protected $guarded = []; protected $guarded = [];
protected static function booted()
{
static::created(function (LocalFileVolume $fileVolume) {
$fileVolume->saveStorageOnServer($fileVolume->service);
});
}
public function service() public function service()
{ {
return $this->morphTo('resource'); return $this->morphTo('resource');
} }
public function saveStorageOnServer(ServiceApplication|ServiceDatabase $service) public function saveStorageOnServer(ServiceApplication|ServiceDatabase $service)
{ {
ray('saveStorageOnServer');
$workdir = $service->service->workdir(); $workdir = $service->service->workdir();
$server = $service->service->server; $server = $service->service->server;
$commands = collect([ $commands = collect([