public function actionPartnerHistory() { $historyModel = new \app\modules\discount\models\History(); $historyModel->scenario = 'search'; $historyModel->load($_POST); $partnerId = \app\modules\discount\models\Partner::getIdByUserId(); $items = $historyModel->findByPartnerId($partnerId); return $this->render('partnerHistory', ['items' => $items, 'historyModel' => $historyModel]); }
public function actionCreate($parentId) { $partner = Partner::findOne($parentId); $model = new Service(); $model->parentId = $parentId; $model->categoryId = $partner->parentId; if ($model->load($_POST) && $model->save()) { return $this->redirect(['/discount/admin/partner/update', 'id' => $parentId, 'section' => 'two']); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Partner::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'dateCreate' => $this->dateCreate, 'visible' => $this->visible, 'parentId' => $this->parentId]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'site', $this->site])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'workTime', $this->workTime])->andFilterWhere(['like', 'phones', $this->phones])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'metaKeywords', $this->metaKeywords])->andFilterWhere(['like', 'metaDescription', $this->metaDescription]); return $dataProvider; }
foreach ($items as $item) { echo $this->render('_serviceCard', ['model' => $item]); } ?> </ul> <div class="page_schet"> <?php echo LinkPager::widget(['pagination' => $pages, 'prevPageCssClass' => 'pager-previo', 'lastPageCssClass' => 'last', 'nextPageCssClass' => 'pager-next']); ?> </div> <div class="map_vk"> <div class="map_bg"> <?php echo \app\modules\cms\components\yandexMap\Map::widget(['points' => \app\modules\discount\models\Partner::getMapPoints()]); ?> </div> <div class="vk"> <script type="text/javascript" src="//vk.com/js/api/openapi.js?116"></script> <!-- VK Widget --> <div id="vk_groups"></div> <script type="text/javascript"> VK.Widgets.Group("vk_groups", {mode: 0, width: "220", height: "400", color1: 'FFFFFF', color2: '2B587A', color3: '5B7FA6'}, 95056247); </script> </div> </div> </div> </div> </div>
public function getPartner() { return $this->hasMany(Partner::className(), ['id' => 'parentId']); }
/** * Finds the Partner model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Partner the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Partner::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }