/**
  * Updates an existing Partner model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id, $section = 'one')
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         $category = new Category();
         $service = new Service();
         $service->parentId = $model->id;
         $serviceDataProvider = $service->search(Yii::$app->request->queryParams);
         return $this->render('update', ['model' => $model, 'category' => $category, 'service' => $service, 'serviceDataProvider' => $serviceDataProvider, 'section' => $section]);
     }
 }
Example #2
0
 public function findByPartnerId($parentId)
 {
     $query = self::find();
     $query->innerJoinWith(['service', 'user']);
     $serviceTable = Service::tableName();
     $query->where([$serviceTable . '.parentId' => $parentId]);
     if (!empty($this->dateUse)) {
         $query->andFilterWhere(['like', 'dateUse', $this->dateUse]);
     }
     return $query->all();
 }
 public function actionSearch($q)
 {
     $this->layout = '//default';
     $model = new Service();
     $items = $model->search(['Service' => ['title' => $q]]);
     return $this->render('search', ['items' => $items, 'q' => $q]);
 }
Example #4
0
 public function getServices()
 {
     return $this->hasMany(Service::className(), ['id' => 'parentId']);
 }
Example #5
0
                        <div class="panel-footer">
                            
                             if($model->userId == \Yii::$app->user->id):?>
                                <a href="" class="btn btn-block b-profile-card__button">Редактировать данные</a>
                            <?php endif?>
                        </div>*/
    ?>
                </div>

            </div>
        <?php 
}
?>

        <?php 
if (\Yii::$app->user->can('partner') && ($services = \app\modules\discount\models\Service::findByUserId(Yii::$app->user->id)) && $model->status == \app\modules\discount\models\Card::STATUS_ACTIVE) {
    ?>
        <div class="col-md-6">

            <div class="panel panel-success">
                <div class="panel-heading">
                    Выбор услуги:
                </div>
                <!-- /.panel-heading -->
                <div class="panel-body">
                    <div class="table-responsive table-bordered">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>Название услуги</th>
 public function actionDelete($id)
 {
     $model = Service::findOne($id);
     $model->delete();
     return $this->redirect(['discount/admin/update', 'id' => $model->parentId, 'section' => 'two']);
 }