- Changed `$cast` to `$casts` in ApplicationSetting model to enable proper boolean casting for new fields. - Added boolean fields: `is_spa`, `is_build_server_enabled`, `is_preserve_repository_enabled`, `is_container_label_escape_enabled`, `is_container_label_readonly_enabled`, and `use_build_secrets`. fix: Update Livewire component to reflect new property names - Updated references in the Livewire component for the new camelCase property names. - Adjusted bindings and IDs for consistency with the updated model. test: Add unit tests for ApplicationSetting boolean casting - Created tests to verify boolean casting for `is_static` and other boolean fields in ApplicationSetting. - Ensured all boolean fields are correctly defined in the casts array. test: Implement tests for SynchronizesModelData trait - Added tests to verify the functionality of the SynchronizesModelData trait, ensuring it correctly syncs properties between the component and the model. - Included tests for handling non-existent properties gracefully.
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ApplicationSetting extends Model
|
|
{
|
|
protected $casts = [
|
|
'is_static' => 'boolean',
|
|
'is_spa' => 'boolean',
|
|
'is_build_server_enabled' => 'boolean',
|
|
'is_preserve_repository_enabled' => 'boolean',
|
|
'is_container_label_escape_enabled' => 'boolean',
|
|
'is_container_label_readonly_enabled' => 'boolean',
|
|
'use_build_secrets' => 'boolean',
|
|
'is_auto_deploy_enabled' => 'boolean',
|
|
'is_force_https_enabled' => 'boolean',
|
|
'is_debug_enabled' => 'boolean',
|
|
'is_preview_deployments_enabled' => 'boolean',
|
|
'is_pr_deployments_public_enabled' => 'boolean',
|
|
'is_git_submodules_enabled' => 'boolean',
|
|
'is_git_lfs_enabled' => 'boolean',
|
|
'is_git_shallow_clone_enabled' => 'boolean',
|
|
];
|
|
|
|
protected $guarded = [];
|
|
|
|
public function isStatic(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
set: function ($value) {
|
|
if ($value) {
|
|
$this->application->ports_exposes = 80;
|
|
}
|
|
$this->application->save();
|
|
|
|
return $value;
|
|
}
|
|
);
|
|
}
|
|
|
|
public function application()
|
|
{
|
|
return $this->belongsTo(Application::class);
|
|
}
|
|
}
|