<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 配置
 */
namespace app\smartbc\model;
use think\Model;

class SmartbcConfig extends Model{

    protected $pk = 'id';
  
    //配置表
    public static function getConfig(int $miniapp_id){
        return self::where(['member_miniapp_id' => $miniapp_id])->find();
    }

   //获取所有配置
    public static function getAllConfig(){
        return self::select();
    }
    
    //编辑
    public static function configs(array $param,int $miniapp_id){
        $rel = self::where(['member_miniapp_id' => $miniapp_id])->find();
        if(empty($rel)){
            $param['member_miniapp_id'] = $miniapp_id;
            return self::insert($param);
        }else{
            return self::where(['member_miniapp_id' => $miniapp_id])->update($param);
        }
    }
}