<?php
|
|
namespace app\operations\model\plus\work;
|
|
use think\facade\Cache;
|
use app\common\model\plus\work\Setting as SettingModel;
|
|
class Setting extends SettingModel
|
{
|
// 定义全局的查询范围
|
protected $globalScope = ['status'];
|
public function scopeStatus($query)
|
{
|
$shop_supplier_ids = \app\operations\model\supplier\Supplier::getSupplierIdsByUser(session('jjjshop_operations')['user']);
|
if (empty($shop_supplier_ids)){
|
$query->where($query->getTable() . '.shop_supplier_id', -1);
|
}else{
|
$query->where($query->getTable() . '.shop_supplier_id', 'in', $shop_supplier_ids);
|
}
|
}
|
/**
|
* 更新系统设置
|
*/
|
public function edit($key, $values, $shop_supplier_id = 0)
|
{
|
$model = self::detail($key, $shop_supplier_id) ?: $this;
|
// 删除系统设置缓存
|
Cache::delete('setting_work' . self::$app_id . '_' . $shop_supplier_id);
|
return $model->save([
|
'key' => $key,
|
'describe' => '基础设置',
|
'values' => $values,
|
'app_id' => self::$app_id,
|
'shop_supplier_id' => $shop_supplier_id
|
]) !== false;
|
}
|
|
}
|