/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tags::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['TagID' => $this->TagID]); $query->andFilterWhere(['like', 'TagDescription', $this->TagDescription]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tags::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, 'created' => $this->created, 'modified' => $this->modified]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tags::getDb()->cache(function ($db) { $query = Tags::find(); $query->joinWith(['tagType', 'parentTag']); return $query; }); $_columns = [Tags::tableName() . '.id', Tags::tableName() . '.tag_name_' . Yii::$app->language, Tags::tableName() . '.tag_type']; $dataProvider = new ActiveDataProvider(['query' => $query]); $query->select($_columns); $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, 'create_date' => $this->create_date]); $query->andFilterWhere(['like', 'tag_name_ar', $this->tag_name_ar])->andFilterWhere(['like', 'tag_name_en', $this->tag_name_en])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'type_name', $this->tag_type]); //->andFilterWhere(['like', 'CONCAT(full_name,username)', $this->created_by]); return $dataProvider; }
public function getTag($aliasOrId) { $tag = Tags::where('id', $aliasOrId)->orWhere('tag_name', $aliasOrId)->firstOrFail(); $diary = Tags::find($tag->id)->diary()->where('diary.status', 1)->orderBy('created_at', 'desc')->paginate(10); return view('site.diary.diary', ['pageInfo' => ['pageLogo' => 'diary', 'siteTitle' => 'Diary by Tag | ' . $tag->tag_name, 'pageHeading' => 'Diary | ' . $tag->tag_name, 'pageHeadingSlogan' => 'I write here what I learn'], 'data' => $diary]); }
* Items category */ Route::resource('items_category', 'ItemsCategoryController'); Route::post('getShop', ['uses' => 'ItemsCategoryController@getShop', 'as' => 'getShop']); $router->post('/ads/flush', 'AdsController@flush'); $router->post('/questions/flush', 'QuestionsController@flush'); $router->post('/questions/upload', 'QuestionsController@store'); $router->post('/questions/{id}', 'QuestionsController@show'); $router->bind('pagename', function ($id) { return \AppAdmin\Models\PageName::find($id); }); $router->bind('categories', function ($id) { return \App\Models\Category::find($id); }); $router->bind('tags', function ($id) { return \App\Models\Tags::find($id); }); $router->bind('ads', function ($id) { return \App\Models\Advertisement::find($id); }); $router->bind('country', function ($title) { return \App\Models\Country::where('title', '=', $title)->first(); }); /** * PROFILE */ $router->bind('profile', function ($user_name) { $user = \App\Models\User::where('user_name', $user_name)->first(); if (!$user) { $user = \App\Models\User::where('user_name', Auth::user()->user_name)->first(); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $data = $request->all(); unset($data['_token']); try { Tags::find($id)->update($data); return redirect()->action('Admin\\TagsController@index')->with(array('dialog' => array('title' => '修改标签成功', 'message' => $data))); } catch (\Exception $e) { return redirect()->back()->withErrors(['error' => '修改标签失败, 请重试'])->with($data); } }
public static function getBlogsByTag($tag) { $list = Tags::find()->where(['name' => $tag])->select(['blog_id'])->asArray()->all(); return self::format($list); }
/** * @return ActiveQuery | array */ public static function getTagsList() { $query = Tags::find()->where(['status' => 'active'])->all(); return ArrayHelper::map($query, 'id', 'tag_name_' . \Yii::$app->language); }