CatQuery.php 946 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace common\models\query;
  3. use common\enums\StatusEnum;
  4. use common\models\Goods;
  5. /**
  6. * This is the ActiveQuery class for [[\common\models\Goods]].
  7. *
  8. * @see \common\models\Goods
  9. */
  10. class CatQuery extends \yii\db\ActiveQuery
  11. {
  12. public function active()
  13. {
  14. return $this->andWhere(['status' => StatusEnum::STATUS_ON, 'is_del' => StatusEnum::STATUS_OFF]);
  15. }
  16. public function notDel()
  17. {
  18. return $this->andWhere(['is_del' => StatusEnum::STATUS_OFF]);
  19. }
  20. public function hot()
  21. {
  22. return $this->andWhere(['is_hot' => StatusEnum::STATUS_ON])->active();
  23. }
  24. /**
  25. * @inheritdoc
  26. * @return \common\models\Goods[]|array
  27. */
  28. public function all($db = null)
  29. {
  30. return parent::all($db);
  31. }
  32. /**
  33. * @inheritdoc
  34. * @return \common\models\Goods|array|null
  35. */
  36. public function one($db = null)
  37. {
  38. return parent::one($db);
  39. }
  40. }