SpecTemplateService.php 843 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace addons\TinyShop\services\common;
  3. use Yii;
  4. use common\enums\StatusEnum;
  5. use common\helpers\ArrayHelper;
  6. use addons\TinyShop\common\models\common\SpecTemplate;
  7. /**
  8. * Class SpecTemplateService
  9. * @package addons\TinyShop\services\common
  10. * @author jianyan74 <751393839@qq.com>
  11. */
  12. class SpecTemplateService
  13. {
  14. /**
  15. * @return array
  16. */
  17. public function getMap()
  18. {
  19. return ArrayHelper::map($this->findAll(), 'id', 'title');
  20. }
  21. /**
  22. * @return array|\yii\db\ActiveRecord[]
  23. */
  24. public function findAll()
  25. {
  26. return SpecTemplate::find()
  27. ->where(['status' => StatusEnum::ENABLED])
  28. ->andWhere(['merchant_id' => Yii::$app->services->merchant->getNotNullId()])
  29. ->orderBy('sort asc, id desc')
  30. ->asArray()
  31. ->all();
  32. }
  33. }
粤ICP备19079148号