Refactor settings form handling: Removed redundant data mutation methods in CreateSetting and EditSetting pages. Updated SettingForm to use distinct fields for text and boolean values, enhancing clarity and functionality. Added new attributes in the Setting model to manage value assignments from different fields.
This commit is contained in:
@@ -13,6 +13,8 @@ class Setting extends Model
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'value',
|
||||
'value_text',
|
||||
'value_boolean',
|
||||
'type',
|
||||
'group',
|
||||
'label',
|
||||
@@ -32,6 +34,22 @@ class Setting extends Model
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* Set value from different field names
|
||||
*/
|
||||
public function setValueTextAttribute($value)
|
||||
{
|
||||
$this->attributes['value'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value from different field names
|
||||
*/
|
||||
public function setValueBooleanAttribute($value)
|
||||
{
|
||||
$this->attributes['value'] = $value ? '1' : '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get setting by key
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user