123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /**
- * @author: xaboy<365615158@qq.com>
- * @day: 2017/11/13
- */
- namespace app\models\system;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- /**
- * 数据组model
- * Class SystemGroup
- * @package app\models\system
- */
- class SystemGroup extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'system_group';
- use ModelTrait;
- /**
- * 根据id获取当前记录中的fields值
- * @param $id
- * @return array
- */
- public static function getField($id)
- {
- $fields = json_decode(self::where('id', $id)->value("fields"), true) ?: [];
- return compact('fields');
- }
- public static function list($where)
- {
- $model = new self;
- if ($where['keyword'] != '') $model = $model->where('config_name|name|info', 'like', '%' . $where['keyword'] . '%');
- $count = $model->count();
- $list = $model->page((int)$where['page'], (int)$where['limit'])->select();
- foreach ($list as $key => $value) {
- $list[$key]['typelist'] = $value['fields'];
- unset($list[$key]['fields']);
- }
- return compact('count', 'list');
- }
- }
|