コード例 #1
0
ファイル: SiteController.php プロジェクト: allakuzmenko/test
 public function actionIndex()
 {
     $query = Publication::find();
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $publications = $query->orderBy('title')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['publications' => $publications, 'pagination' => $pagination]);
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Publication::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, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'descriptoin', $this->descriptoin])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Publication::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_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'title_pt', $this->title_pt])->andFilterWhere(['like', 'summary_en', $this->summary_en])->andFilterWhere(['like', 'summary_pt', $this->summary_pt])->andFilterWhere(['like', 'content_en', $this->content_en])->andFilterWhere(['like', 'content_pt', $this->content_pt]);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $facultyId 
  * @param  int  $id
  * @return Response
  */
 public function destroy($facultyId, $id)
 {
     $publication = Publication::find($id);
     $publication->researchArea()->sync([]);
     $publication->delete();
     Flash::success('Publication created successfully');
     return redirect("/admin/faculty/{$facultyId}");
 }
コード例 #5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function publish($id)
 {
     $pub = Publication::find($id);
     $pub->update(['is_published' => $pub->is_published ? 0 : 1]);
     return Redirect::route('publications.admin');
 }