AutoPink.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\models\lala;
  3. use app\models\mining\UserMiningMachine;
  4. use app\models\system\SystemMoney;
  5. use app\models\user\User;
  6. use app\models\user\UserMoney;
  7. use Exception;
  8. use think\db\exception\DataNotFoundException;
  9. use think\db\exception\DbException;
  10. use think\db\exception\ModelNotFoundException;
  11. use crmeb\traits\ModelTrait;
  12. use crmeb\basic\BaseModel;
  13. /**
  14. * TODO 文章Model
  15. * Class Article
  16. * @package app\models\article
  17. */
  18. class AutoPink extends BaseModel
  19. {
  20. /**
  21. * 数据表主键
  22. * @var string
  23. */
  24. protected $pk = 'id';
  25. /**
  26. * 模型名称
  27. * @var string
  28. */
  29. protected $name = 'auto_pink';
  30. use ModelTrait;
  31. /**
  32. * @return AutoPink
  33. */
  34. public static function validWhere($admin = false)
  35. {
  36. return $admin ? self::where('is_del', 0) : self::where('is_show', 1)->where('is_del', 0);
  37. }
  38. /**
  39. * @param $where
  40. * @param $page
  41. * @param $limit
  42. * @param bool $admin
  43. * @return array
  44. */
  45. public static function getList($where, $page, $limit, bool $admin = false): array
  46. {
  47. $model = self::validWhere($admin);
  48. if (isset($where['is_show']) && $where['is_show'] != '') $model = $model->where('is_show', $where['is_show']);
  49. if (isset($where['title']) && $where['title'] != '') $model = $model->where('name', 'like', "%" . $where['title'] . "%");
  50. if (isset($where['lala_id']) && $where['lala_id'] != '') $model = $model->where("FIND_IN_SET('" . $where['lala_id'] . "',lala_id)");
  51. $data = $model->page((int)$page, (int)$limit)->select()->each(function ($item){
  52. $item['money_type'] = get_money_name($item['money_type']);
  53. });
  54. $count = $model->count();
  55. return compact('data', 'count');
  56. }
  57. }