Skip to content

Commit

Permalink
Merge pull request #29 from okumurakengo/feature/value-empty-string-a…
Browse files Browse the repository at this point in the history
…llowed

empty string allowed for value column
  • Loading branch information
z-song authored Dec 11, 2019
2 parents 5fe99f5 + a5f724a commit 62e3456
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ public function form()

$form->display('id', 'ID');
$form->text('name')->rules('required');
$form->textarea('value')->rules('required');
if (config('admin.extensions.config.valueEmptyStringAllowed', false)) {
$form->textarea('value');
} else {
$form->textarea('value')->rules('required');
}
$form->textarea('description');

$form->display('created_at');
Expand Down
14 changes: 14 additions & 0 deletions src/ConfigModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,18 @@ public function __construct($attributes = [])

$this->setTable(config('admin.extensions.config.table', 'admin_config'));
}

/**
* Set the config's value.
*
* @param string|null $value
*/
public function setValueAttribute($value = null)
{
if (config('admin.extensions.config.valueEmptyStringAllowed', false)) {
$this->attributes['value'] = is_null($value) ? '' : $value;
} else {
$this->attributes['value'] = $value;
}
}
}

0 comments on commit 62e3456

Please sign in to comment.