public function actionOther() { $query = Service::find()->where(['state' => Service::STATE_PUBLISH])->orderBy(['createDate' => SORT_DESC]); $pagination = new Pagination(['defaultPageSize' => 20, 'totalCount' => $query->count()]); $models = $query->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('other', ['models' => $models, 'pages' => $pagination]); }
static function getPrice($example_id) { $services = Service::find()->innerJoinWith('example_service')->where(['example_service.example_id' => $example_id])->all(); //ExampleService::find()->where(['example_id' => $example_id])->all(); $price = 0; foreach ($services as $service) { $price += $service->price; } return $price; }
/** * Lists all Service models. * @return mixed */ public function actionIndex() { $this->view->title = Yii::t('app', 'Services'); $models = Service::find()->asArray()->all(); $services = []; foreach ($models as $model) { $services[$model['name']] = $model; } return $this->render('index', ['services' => $services]); }
/** * Deletes an existing ServiceCategory model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $serviceService = Service::find()->andWhere(['category_id' => $id])->one(); if (null === $serviceService) { $this->findService($id)->delete(); } else { Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for service #' . $serviceService->id . ' before delete.'), 'options' => ['class' => 'alert-error']]); } return $this->redirect(['index']); }
public function search($params) { $query = Service::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'IP', $this->IP])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]); return $dataProvider; }
public function search($params) { $query = Service::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'type_id' => $this->type_id, 'organization_id' => $this->organization_id, 'price' => $this->price]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'code', $this->code]); return $dataProvider; }
/** * Lists all Service models. * @return mixed */ public function actionIndex($p = 1) { // $dataProvider = new ActiveDataProvider([ // 'query' => Service::find(), // ]); // return $this->render('index', [ // 'dataProvider' => $dataProvider, // ]); $page = Service::find()->where(['id' => $p])->one(); return $this->render('page', ['page' => $page]); }
/** * 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, 'pagination' => ['pageSize' => 10]]); $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, 'order' => $this->order]); $query->andFilterWhere(['like', 'sid', $this->sid])->andFilterWhere(['like', 'header', $this->header])->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Service::find(); if (!\Yii::$app->user->can('administrator')) { $query->forDomain(); } $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'domain_id' => $this->domain_id]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'price', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]); return $dataProvider; }
public function actionView($sid) { $service = Service::find()->select('*')->innerJoinWith('secs')->where(['service.sid' => $sid])->one(); $page = Page::find()->where(['sid' => Yii::$app->controller->id])->select(['id', 'pid', 'sid', 'header'])->one(); $pages = Page::find()->select(['id', 'pid', 'sid', 'header'])->asArray()->indexBy('id')->all(); $mode = $pages[$page->id]; $branch[] = $mode; while (!is_null($mode['pid'])) { $mode = $pages[$mode['pid']]; $branch[] = $mode; } krsort($branch); $branch[] = ['header' => $service->header]; return $this->render('view', ['service' => $service, 'branch' => $branch]); }
/** * Lists all ServicePage models. * @return mixed */ public function actionIndex() { $searchModel = new ServicePageSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider->sort = ['defaultOrder' => ['published_at' => SORT_DESC]]; $dataProvider->query->andFilterWhere(['locale' => Yii::$app->language]); if (Yii::$app->request->get('mid')) { $parentModel = Service::find(['id' => Yii::$app->request->get('mid')])->one(); $parentModel = Service::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA', 'locale_group_id' => $parentModel->locale_group_id])->one(); $models = ServicePage::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA', 'service_id' => $parentModel->id])->all(); } else { $models = ServicePage::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA'])->all(); } $list = \yii\helpers\ArrayHelper::map($models, 'locale_group_id', 'title'); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'list' => $list]); }
public function actionSearch() { $request = Yii::$app->request; $type = $request->get("type"); $query = Yii::$app->session->getFlash('query'); if (!$type) { $type = $request->post("type"); $content = $request->post("content"); } else { $content = $request->get("content"); } if ($type || !$query) { switch ($type) { case 'userId': $query = Service::find()->where(['userId' => $content]); break; case 'date': $query = Service::find()->where(['between', 'createDate', date('Y-m-d H:i:s', strtotime($content)), date('Y-m-d H:i:s')]); break; case 'state': if ($content == 'noReply') { $query = Service::find()->where(['state' => Service::STATE_UNREPLY]); } elseif ($content == 'replied') { $query = Service::find()->where(['state' => Service::STATE_REPLIED]); } elseif ($content == 'publish') { $query = Service::find()->where(['state' => Service::STATE_PUBLISH]); } else { $query = Service::find(); } break; case 'nickname': $table_a = Service::tableName(); $table_b = Users::tableName(); $query = Service::find()->leftJoin($table_b, "{$table_a}.userId={$table_b}.userId")->where(['like', "{$table_b}.nickname", $content]); break; case 'content': $query = Service::find()->where(['like', $type, $content]); break; default: $query = Service::find(); break; } } $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]); $models = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['createDate' => SORT_DESC])->all(); return $this->render('index', ['models' => $models, 'pages' => $pagination]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Service::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'token', $this->token])->andFilterWhere(['like', 'data', $this->data]); //$query->andFilterWhere([ // 'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at, //]); return $dataProvider; }
/** * Creates a new Service model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { foreach (Yii::$app->params['availableLocales'] as $key => $value) { $currentService = Service::getLocaleInstance($key); $currentService->locale = $key; if (Yii::$app->request->get('scenario')) { $currentService->on_scenario = Yii::$app->request->get('scenario'); } $services[$key] = $currentService; } //set data from default service if (Yii::$app->request->get('locale_group_id')) { $defaultDomainServices = Service::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale_group_id' => Yii::$app->request->get('locale_group_id')])->all(); foreach ($defaultDomainServices as $key => $value) { if (!in_array($value->locale, array_keys(Yii::$app->params['availableLocales']))) { continue; } $services[$value->locale]->slug = $value->slug; $services[$value->locale]->title = $value->title; $services[$value->locale]->head = $value->head; $services[$value->locale]->body = $value->body; $services[$value->locale]->price = $value->price; $services[$value->locale]->description = $value->description; $services[$value->locale]->thumbnail = $value->thumbnail; $services[$value->locale]->before_body = $value->before_body; $services[$value->locale]->after_body = $value->after_body; } } $service = new MultiModel(['models' => $services]); if ($service->load(Yii::$app->request->post()) && Service::multiSave($service)) { return $this->redirect(['index']); } else { switch (Yii::$app->request->get('scenario')) { case 'extend': $viewName = 'extend'; break; default: $viewName = 'create'; } return $this->render($viewName, ['model' => $service, 'categories' => ServiceCategory::find()->active()->all(), 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]); } }
/** * Lists all Service models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Service::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use common\models\Service; use common\models\Type; $types = ArrayHelper::map(Type::find()->asArray()->all(), 'type_id', 'title'); $services = ArrayHelper::map(Service::find()->where(['parent_id' => 0])->asArray()->all(), 'id', 'title'); ?> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <div class="row"> <div class="col-md-4"> <?php echo $form->field($model, 'landing_id')->textInput(['readonly' => true]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'type_id')->dropDownList($types); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'service_id')->dropDownList($services); ?> </div>
$form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'service_id')->dropDownList(ArrayHelper::map(Service::find()->where(['parent_id' => 0])->asArray()->all(), 'id', 'title')); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'service')->checkboxList(ArrayHelper::map(Service::find()->all(), 'id', 'title')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
<? use yii\bootstrap\Tabs; use common\models\Service; // Услуги по данному примеру $services = Service::find()->where(['parent_id' => $model->service_id])->orderBy('sorting')->all(); // Определяем вкладки $all=' <div class="row"> <div class="col-md-4">'. $this->render("advantages/_advantage",["model" => $services[0] ]) .'</div> <div class="col-md-4">'. $this->render("advantages/_advantage",["model" => $services[2] ]) .'</div> <div class="col-md-4">'. $this->render("advantages/_advantage",["model" => $services[4] ]) .'</div> </div> <div class="row hidden-xs hidden-sm"> <div style="position:relative; top:35px; background: url(/image/shadow_ffffff_percent_50.png); z-index:2; height:20px;"></div> <div class="col-md-1 col-md-offset-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> </div>
public function actionSitemap() { $listtext = Text::find()->where(['on' => 1])->all(); $listservice = Service::find()->where(['on' => 1])->all(); return $this->render('sitemap', ['listtext' => $listtext, 'listservice' => $listservice]); }
public function afterDelete() { $service = Service::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one(); if ($service) { $service->delete(); } return parent::afterDelete(); }
/** * 查询发布的咨询,缓存1分钟 * @param null $limit * @return array|\yii\db\ActiveRecord[] */ public static function findPublished($limit = null) { if ($limit) { return Service::getDb()->cache(function () use($limit) { return Service::find()->where(['state' => Service::STATE_PUBLISH])->limit($limit)->orderBy(['replyDate' => SORT_DESC])->all(); }, 60); } else { return Service::getDb()->cache(function () { return Service::find()->where(['state' => Service::STATE_PUBLISH])->orderBy(['replyDate' => SORT_DESC])->all(); }, 60); } }
/** * @inheritdoc */ static function getTopServices($parent_id = 0) { $models = Service::find()->where(['parent_id' => $parent_id])->orderBy(['sorting' => SORT_ASC]); return $models; }