| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Module\System\Admin\Actions;
- use App\Module\System\Models\SysConfig;
- use App\Module\System\Services\Config;
- use Illuminate\Support\Facades\DB;
- trait ConfigEditForm
- {
- 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();
- Config::clear_cache();
- }catch (\Exception $exception){
- DB::rollBack();
- }
- return $this->success('ok')->refresh();
- }
- }
|