ManyDiscipline.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @author: xaboy<365615158@qq.com>
  4. * @day: 2017/11/11
  5. */
  6. namespace app\models\many;
  7. use crmeb\services\PHPExcelService;
  8. use crmeb\traits\ModelTrait;
  9. use crmeb\basic\BaseModel;
  10. /**
  11. * Class StoreCategory
  12. * @package app\admin\model\store
  13. */
  14. class ManyDiscipline extends BaseModel
  15. {
  16. /**
  17. * 数据表主键
  18. * @var string
  19. */
  20. protected $pk = 'id';
  21. /**
  22. * 模型名称
  23. * @var string
  24. */
  25. protected $name = 'many_discipline';
  26. use ModelTrait;
  27. protected $autoWriteTimestamp = true;
  28. public static function list($where)
  29. {
  30. $model = self::alias('a')
  31. ->field('a.*,b.name')
  32. ->leftJoin('many b', 'b.id = a.many_id');
  33. if ($where['stage'])$model->where('a.stage' , '=', $where['stage']);
  34. if (trim($where['many_id']) != '')$model->where('b.id' , '=', $where['many_id']);
  35. if (trim($where['data']) != '') $model = self::getModelTime($where, $model, 'a.create_time');
  36. $data['count'] = $model->count();
  37. if (isset($where['excel']) && $where['excel'] == 1) {
  38. $list = ($list = $model->select()) && count($list) ? $list->toArray() : [];
  39. } else {
  40. $list = ($list = $model->page((int)$where['page'], (int)$where['limit'])->select()) && count($list) ? $list->toArray() : [];
  41. }
  42. if (isset($where['excel']) && $where['excel'] == 1) {
  43. self::SaveExcel($list);
  44. }
  45. if ($where['page'] && $where['limit']){
  46. $model->page($where['page'], $where['limit']);
  47. }else{
  48. $model->page(20, 1);
  49. }
  50. $list = $model->select()->toArray();
  51. $data['data'] = $list;
  52. return $data;
  53. }
  54. }