coolify/app/Models/ApplicationSetting.php

50 lines
1.4 KiB
PHP
Raw Normal View History

2023-03-28 15:47:37 +02:00
<?php
namespace App\Models;
2023-04-26 13:01:09 +02:00
use Illuminate\Database\Eloquent\Casts\Attribute;
2023-03-28 15:47:37 +02:00
use Illuminate\Database\Eloquent\Model;
class ApplicationSetting extends Model
{
2023-05-31 11:24:02 +02:00
protected $cast = [
'is_static' => 'boolean',
'is_auto_deploy_enabled' => 'boolean',
'is_force_https_enabled' => 'boolean',
'is_debug_enabled' => 'boolean',
'is_preview_deployments_enabled' => 'boolean',
'is_git_submodules_enabled' => 'boolean',
'is_git_lfs_enabled' => 'boolean',
];
2023-04-19 14:00:31 +02:00
protected $fillable = [
2023-04-25 14:43:35 +02:00
'application_id',
2023-05-31 11:24:02 +02:00
'is_static',
'is_auto_deploy_enabled',
'is_force_https_enabled',
'is_debug_enabled',
'is_preview_deployments_enabled',
'is_git_submodules_enabled',
'is_git_lfs_enabled',
2023-04-19 14:00:31 +02:00
];
2023-04-26 13:01:09 +02:00
public function isStatic(): Attribute
{
return Attribute::make(
set: function ($value) {
2023-05-22 09:53:31 +02:00
if (is_null($this->application->ports_exposes)) {
if ($value) {
$this->application->ports_exposes = '80';
} else {
$this->application->ports_exposes = '3000';
}
$this->application->save();
2023-04-26 13:01:09 +02:00
}
return $value;
}
);
}
public function application()
{
return $this->belongsTo(Application::class);
}
2023-03-28 15:47:37 +02:00
}