1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace app\models\course;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- class CourseModel extends BaseModel
- {
- /**
- * 数据表主键
- * @var string
- */
- protected $pk = 'id';
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'course';
- use ModelTrait;
- public static function systemPage($where)
- {
- $model = new self;
- if (isset($where['area']) && $where['area'] !== '') $model = $model->where('area', $where['area']);
- if (isset($where['title']) && $where['title'] !== '') $model = $model->where('title', 'LIKE', "%$where[title]%");
- $model = $model->where('is_del', 0);
- $model = $model->order('sort desc,id desc');
- $count = $model->count();
- $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
- $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
- })->toArray();
- return compact('count', 'list');
- }
- /**
- * 详情
- */
- public static function getOne($id)
- {
- $info = self::where('is_del', 0)->find($id);
- return $info;
- }
- }
|