SupplierController.php 1.4 KB

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