ManageLogic.php 1.9 KB
<?php

namespace App\Http\Logic\Aside\Manage;


use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\Manage;
use App\Models\Manage\Menu;
use Illuminate\Support\Facades\Hash;

/**
 * Class ManageLogic
 * @package App\Http\Logic\Aside\Manage
 * @author zbj
 * @date 2023/4/20
 */
class ManageLogic extends  BaseLogic
{
    public function __construct()
    {
        parent::__construct();
        $this->param = $this->requestAll;
        $this->model = new Manage();
    }

    public function managerSave(){
        if(isset($this->param['password']) && !empty($this->param['password'])){
            $this->param['password'] = Hash::make($this->param['password']);
        }
        if(isset($this->param['id']) && !empty($this->param['id'])){
            $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
        }else{
            $rs = $this->model->add($this->param);
        }
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }


    public function getCacheName($id){
        $info = $this->model->read(['id'=>$id]);
        return $info['name'] ?? '';
    }

    /**
     * @remark :设置排序
     * @name   :setSort
     * @author :lyh
     * @method :post
     * @time   :2023/8/10 16:42
     */
    public function setParamStatus(){
        $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
        if($rs === false){
            $this->fail('修改失败');
        }
        return $this->success();
    }

    /**
     * @remark :获取数据详情
     * @name   :getManagerInfo
     * @author :lyh
     * @method :post
     * @time   :2023/8/28 16:10
     */
    public function getManagerInfo(){
        $info = $this->model->read(['id'=>$this->param['id']]);
        if($info === false){
            $this->fail('error');
        }
        return $this->success($info);
    }


}