AttachmentCateService.php 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace services\common;
  3. use Yii;
  4. use common\components\Service;
  5. use common\enums\StatusEnum;
  6. use common\helpers\ArrayHelper;
  7. use common\models\common\AttachmentCate;
  8. /**
  9. * Class AttachmentCateService
  10. * @package services\common
  11. */
  12. class AttachmentCateService extends Service
  13. {
  14. /**
  15. * @return array
  16. */
  17. public function getMap($type)
  18. {
  19. return ArrayHelper::map($this->findAll($type), 'id', 'title');
  20. }
  21. /**
  22. * @return array|\yii\db\ActiveRecord[]
  23. */
  24. public function findAll($type)
  25. {
  26. return AttachmentCate::find()
  27. ->where([
  28. 'type' => $type,
  29. 'status' => StatusEnum::ENABLED
  30. ])
  31. ->andWhere([
  32. 'merchant_id' => Yii::$app->services->merchant->getNotNullId(),
  33. 'store_id' => Yii::$app->services->store->getNotNullId(),
  34. ])
  35. ->asArray()
  36. ->all();
  37. }
  38. }
粤ICP备19079148号