| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace addons\TinyShop\merchant\modules\common\controllers;
- use Yii;
- use common\enums\StatusEnum;
- use common\traits\MerchantCurd;
- use common\models\base\SearchModel;
- use addons\TinyShop\common\models\common\NotifyAnnounce;
- use addons\TinyShop\backend\controllers\BaseController;
- /**
- * 公告
- *
- * Class NotifyAnnounceController
- * @package addons\TinyShop\merchant\modules\common\controllers
- * @author jianyan74 <751393839@qq.com>
- */
- class NotifyAnnounceController extends BaseController
- {
- use MerchantCurd;
- /**
- * @var NotifyAnnounce
- */
- public $modelClass = NotifyAnnounce::class;
- /**
- * @return string
- * @throws \yii\web\NotFoundHttpException
- */
- public function actionIndex()
- {
- $searchModel = new SearchModel([
- 'model' => $this->modelClass,
- 'scenario' => 'default',
- 'partialMatchAttributes' => ['title'], // 模糊查询
- 'defaultOrder' => [
- 'id' => SORT_DESC,
- ],
- 'pageSize' => $this->pageSize,
- ]);
- $dataProvider = $searchModel
- ->search(Yii::$app->request->queryParams);
- $dataProvider->query
- ->andWhere(['>=', 'status', StatusEnum::DISABLED])
- ->andWhere(['merchant_id' => $this->getMerchantId()]);
- return $this->render($this->action->id, [
- 'dataProvider' => $dataProvider,
- 'searchModel' => $searchModel,
- ]);
- }
- /**
- * 编辑/创建
- *
- * @return mixed
- */
- public function actionEdit()
- {
- $id = Yii::$app->request->get('id', null);
- $model = $this->findModel($id);
- $model->member_id = Yii::$app->user->id;
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['index']);
- }
- return $this->render($this->action->id, [
- 'model' => $model,
- ]);
- }
- }
|