1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- * @author: xaboy<365615158@qq.com>
- * @day: 2017/11/11
- */
- namespace app\models\many;
- use crmeb\services\PHPExcelService;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- /**
- * Class StoreCategory
- * @package app\admin\model\store
- */
- class ManyDiscipline extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'many_discipline';
- use ModelTrait;
- protected $autoWriteTimestamp = true;
- public static function list($where)
- {
- $model = self::alias('a')
- ->field('a.*,b.name')
- ->leftJoin('many b', 'b.id = a.many_id');
- if ($where['stage'])$model->where('a.stage' , '=', $where['stage']);
- if (trim($where['many_id']) != '')$model->where('b.id' , '=', $where['many_id']);
- if (trim($where['data']) != '') $model = self::getModelTime($where, $model, 'a.create_time');
- $data['count'] = $model->count();
- if (isset($where['excel']) && $where['excel'] == 1) {
- $list = ($list = $model->select()) && count($list) ? $list->toArray() : [];
- } else {
- $list = ($list = $model->page((int)$where['page'], (int)$where['limit'])->select()) && count($list) ? $list->toArray() : [];
- }
- if (isset($where['excel']) && $where['excel'] == 1) {
- self::SaveExcel($list);
- }
- if ($where['page'] && $where['limit']){
- $model->page($where['page'], $where['limit']);
- }else{
- $model->page(20, 1);
- }
- $list = $model->select()->toArray();
- $data['data'] = $list;
- return $data;
- }
- }
|