HousePrice.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace common\models;
  3. class HousePrice extends AllclickRecord
  4. {
  5. public function rules()
  6. {
  7. return [
  8. ['price', 'required', 'message' => '户型不能为空'],
  9. ['state', 'in', 'range' => [1, 2]],
  10. ['del', 'in', 'range' => [1, 2]],
  11. ];
  12. }
  13. public function FindById($id)
  14. {
  15. return self::findOne($id);
  16. }
  17. public function getList($input, $arr = null)
  18. {
  19. $query = self::find();
  20. $query->select($arr);
  21. $query = $this->WhereFouse($query);
  22. if (!empty($input['page'])) {
  23. $query->offset = ($input['page'] - 1) * $input['limit'];
  24. $query->limit = $input['limit'];
  25. }
  26. return $query->orderBy(['sort' => SORT_ASC])->asArray()->all();
  27. }
  28. public function WhereFouse($query)
  29. {
  30. $query->andFilterWhere(['del' => $this->setDel]);
  31. $query->andFilterWhere(['price' => $this->price]);
  32. $query->andFilterWhere(['state' => $this->state]);
  33. return $query;
  34. }
  35. public function Total()
  36. {
  37. $query = self::find();
  38. $query = $this->WhereFouse($query);
  39. return $query->count();
  40. }
  41. }