yunzer/app/admin/model/YzAdminConfig.php
2025-04-25 17:27:26 +08:00

43 lines
879 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 配置表
*/
namespace app\admin\model;
use app\admin\model\Base;
class YzAdminConfig extends Base{
protected $pk = 'config_id';
/**
* 列出全部配置key对应value
*/
public function getAll(){
$aList = static::where('config_status',1)->order('config_sort DESC')->select()->toArray();
if(empty($aList)){
return [];
}else{
$return = [];
foreach($aList as $k=>$v){
$return[$v['config_name']] = $v['config_value'];
}
}
return $return;
}
/**
* 多条数据更新
*/
public function updateAll($data){
$lists = static::order('config_sort DESC,config_id')->select()->toArray();
if(empty($lists)){
return false;
}else{
foreach($lists as &$lists_v){
$lists_v['config_value'] = $data[$lists_v['config_name']];
}
$save = static::saveAll($lists);
if(empty($save)){
return false;
}
}
return true;
}
}