| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App\Module\System\Admin\Actions;
- use App\Module\System\Models\SysConfig;
- use App\Module\System\Services\Config;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Traits\LazyWidget;
- use Illuminate\Support\Facades\DB;
- use UCore\DcatAdmin\Widgets\Form;
- /**
- * 字符串配置 修改表单
- *
- */
- class ConfigStringEditForm extends Form implements LazyRenderable
- {
- use LazyWidget,ConfigEditForm;
- public function __construct($data = [], $key = null)
- {
- parent::__construct($data, $key);
- // dump(func_get_args());
- }
- public function run($input)
- {
- $id = $this->payload['id'] ?? null;
- if (!$id) {
- return $this->error('input-error');
- }
- /**
- * @var SysConfig $model
- */
- $model = SysConfig::query()->find($id);
- // dump($model);
- if(!$model){
- return $this->error('noinfo');
- }
- try {
- DB::beginTransaction();;
- $model->value = $input['value'];
- if(!$model->save()){
- return $this->error('error');
- }
- DB::commit();
- }catch (\Exception $exception){
- DB::rollBack();
- }
- return $this->success('ok')->refresh();
- }
- public function form()
- {
- $id = $this->payload['id'] ?? null;
- $model = SysConfig::query()->find($id);
- if(!$model){
- return $this->error('错误的')->refresh();
- }
- $this->display('k','Key')->value($model->keyname);
- $this->display('k','标题')->value($model->title);
- $this->display('k','描述')->value($model->desc);
- $this->text('value',"内容")->default($model->value)->required();
- }
- }
|