CourseModel.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\models\course;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. class CourseModel extends BaseModel
  6. {
  7. /**
  8. * 数据表主键
  9. * @var string
  10. */
  11. protected $pk = 'id';
  12. /**
  13. * 模型名称
  14. * @var string
  15. */
  16. protected $name = 'course';
  17. use ModelTrait;
  18. public static function systemPage($where)
  19. {
  20. $model = new self;
  21. if (isset($where['area']) && $where['area'] !== '') $model = $model->where('area', $where['area']);
  22. if (isset($where['title']) && $where['title'] !== '') $model = $model->where('title', 'LIKE', "%$where[title]%");
  23. $model = $model->where('is_del', 0);
  24. $model = $model->order('sort desc,id desc');
  25. $count = $model->count();
  26. $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
  27. $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
  28. })->toArray();
  29. return compact('count', 'list');
  30. }
  31. /**
  32. * 详情
  33. */
  34. public static function getOne($id)
  35. {
  36. $info = self::where('is_del', 0)->find($id);
  37. return $info;
  38. }
  39. }