WebSettingTextLogic.php 1.7 KB
<?php

namespace App\Http\Logic\Bside\Setting;

use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSetting;
use App\Models\WebSetting\WebSettingText;
use Illuminate\Support\Facades\DB;

class WebSettingTextLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();

        $this->model = new WebSettingText();
        $this->param = $this->requestAll;
    }

    /**
     * @name   :(描文本详情)setting_text_lists
     * @author :lyh
     * @method :post
     * @time   :2023/5/8 14:18
     */
    public function setting_text_lists(){
        $lists = $this->model->list(['project_id'=>$this->user['project_id']],'created_at');
        $web_setting = new WebSetting();
        $setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting']);
        $lists['anchor_info'] = $setting_info;
        $anchor_text = config('setting.anchor_text');
        $lists['anchor_text'] = $anchor_text;
        $this->success($lists);
    }

    /**
     * @name   :(设置描文本)setting_text_save
     * @author :lyh
     * @method :post
     * @time   :2023/5/8 14:39
     */
    public function setting_text_save(){
        DB::beginTransaction();
        try {
            //更新描文本设置
            $web_setting = new WebSetting();
            $web_setting->edit(['anchor_setting'=>$this->param['anchor_setting']],['project_id'=>$this->user['project_id']]);
            $this->model->del(['project_id'=>$this->user['project_id']]);
            $this->model->add($this->param['data']);
            DB::commit();
        }catch (\Exception $e){
            DB::rollBack();
            $this->fail('更新失败');
        }
        $this->success();
    }
}