AuthController.php 1.5 KB

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