Пример #1
0
 public function actionIndex()
 {
     $services = Service::find()->where(['status' => '1']);
     if ($_GET['category'] != '') {
         $services = $services->andWhere(['category_id' => $_GET['category']]);
     }
     return $this->render('index', ['services' => $services->all()]);
 }
Пример #2
0
 /**
  * Creates a new Service model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     session_start();
     $_SESSION['Service']['id'] = Service::find()->max('id') + 1;
     $model = new Service();
     $media = Media::find()->where(['service_id' => $_SESSION['Service']['id']])->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'media' => $media]);
     }
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Service::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'owner' => $this->owner]);
     $query->andFilterWhere(['like', 'can_reserve', $this->can_reserve])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'socials', $this->socials])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Пример #4
0
 public function actionIndex($catslug, $slug)
 {
     $service = Service::find()->where(['slug' => $slug])->one();
     return $this->render('index', ['service' => $service]);
 }
Пример #5
0
 public function getService()
 {
     return Service::find()->where(['id' => $this->service_id])->one();
 }
Пример #6
0
 public function getServices()
 {
     return Service::find()->where(['category_id' => $this->id, 'status' => '1'])->all();
 }
Пример #7
0
 public function actionCheckService($id)
 {
     if (Yii::$app->request->isAjax) {
         if (Yii::$app->user->isGuest) {
             return $this->redirect(array('site/login', 'id' => 302));
         }
         $service = Service::find()->where(['id' => $id])->one();
         $checklist = new Checklist();
         $checklist->user_id = Yii::$app->user->id;
         $checklist->category_id = $service->category_id;
         $checklist->service_id = $service->id;
         if ($checklist->save()) {
             $list = '<li class="toolbar_item"><a href="#" class="disabled" data-view="' . $service->category->slug . '" class="checklist-category"><i class="zmdi zmdi-hc-3x ' . $service->category->icon . '"></i><span>' . $service->category->name . '</span></a></li>';
             $category_input = '<input id="plan-input-' . $service->category->slug . '" class="plan-input-service" type="text" data-value="" name="plan-input-' . $service->category->slug . '" style="display: none"/>';
             $category_p = '<p>' . $service->category->name . ': <span class="plan_category_span" data-id="plan-input-' . $service->category->slug . '"></span>';
             $category_block = '<div id="' . $service->category->slug . '" class="plan-content-view plan-content-service">
                                     <div class="plan-content-header">
                                         <div class="plan-content-input" data-placeholder="' . $service->category->name . '">' . $service->category->name . '</div>
                                         <a class="waves-effect waves-black btn right enter"><i class="zmdi zmdi-check zmdi-hc-2x"></i></a>
                                         <a class="waves-effect waves-black btn left close"><i class="zmdi zmdi-close zmdi-hc-2x"></i></a>
                                     </div>
                                     <div class="row">
                                         <div class="plan-content-view-body">
                                             <div class="plan-services-page">
                                             </div>
                                         </div>
                                     </div>
                                 </div>';
             $service = '<div class="col s12 m6 l3">
                             <div class="ih-item circle effect3 left_to_right">
                                 <div class="ih-item-hover">
                                     <div data-url="#" class="img z-depth-1">
                                         <a class="valign-wrapper">
                                             <img src="/uploads/services/' . $service->img . '" alt="img">
                                             <h4 class="valign">' . $service->name . '</h4>
                                         </a>
                                     </div>
                                     <div class="info z-depth-1 valign-wrapper">
                                         <div class="info-description valign">
                                             <h4>' . $service->name . '</h4>
                                             <ul class="product_rating">
                                               <li><i class="zmdi zmdi-calendar"></i> 14</li>
                                               <li><i class="zmdi zmdi-star-outline"></i> 23</li>
                                               <li><i class="zmdi zmdi-favorite-outline"></i> 34</li>
                                             </ul>
                                         </div>
                                     </div>
                                     <div class="buttons">
                                         <a class="add_btn btn-floating btn-large waves-effect waves-light" tabindex="0" data-input="plan-input-' . $service->category->slug . '" data-id="' . $service->id . '" data-category="' . $service->category->slug . '"><i class="zmdi zmdi-hc-3x zmdi-check"></i></a>
                                         <a class="view_btn btn-floating btn-large waves-effect waves-light" tabindex="0"><i class="zmdi zmdi-hc-3x zmdi-search"></i></a>
                                     </div>
                                 </div>
                             </div>
                         </div>';
             $check = true;
         } else {
             $check = false;
         }
         die(Json::encode(['list' => $list, 'category_input' => $category_input, 'category_p' => $category_p, 'category_block' => $category_block, 'service' => $service, 'check' => $check]));
     }
 }