AdvController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace addons\TinyShop\merchant\modules\common\controllers;
  3. use Yii;
  4. use common\enums\StatusEnum;
  5. use common\models\base\SearchModel;
  6. use common\traits\MerchantCurd;
  7. use addons\TinyShop\common\models\common\Adv;
  8. use addons\TinyShop\merchant\controllers\BaseController;
  9. /**
  10. * 幻灯片
  11. *
  12. * Class AdvController
  13. * @package addons\TinyShop\merchant\modules\common\controllers
  14. * @author jianyan74 <751393839@qq.com>
  15. */
  16. class AdvController extends BaseController
  17. {
  18. use MerchantCurd;
  19. /**
  20. * @var Adv
  21. */
  22. public $modelClass = Adv::class;
  23. /**
  24. * 首页
  25. *
  26. * @return string
  27. * @throws \yii\web\NotFoundHttpException
  28. */
  29. public function actionIndex()
  30. {
  31. $searchModel = new SearchModel([
  32. 'model' => $this->modelClass,
  33. 'scenario' => 'default',
  34. 'partialMatchAttributes' => ['title'], // 模糊查询
  35. 'defaultOrder' => [
  36. 'sort' => SORT_ASC,
  37. 'id' => SORT_DESC,
  38. ],
  39. 'pageSize' => $this->pageSize,
  40. ]);
  41. $dataProvider = $searchModel
  42. ->search(Yii::$app->request->queryParams);
  43. $dataProvider->query
  44. ->andWhere(['>=', 'status', StatusEnum::DISABLED])
  45. ->andWhere(['merchant_id' => $this->getMerchantId()]);
  46. return $this->render($this->action->id, [
  47. 'dataProvider' => $dataProvider,
  48. 'searchModel' => $searchModel,
  49. ]);
  50. }
  51. }
粤ICP备19079148号