public function movie($id) { $movie = Movie::find($id); $notes = Note::where('movie_id', $movie->_id)->orderBy('note', 'DESC')->get(); $data = ['movie' => $movie, 'notes' => $notes]; return view('movie', $data); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Movie::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(['year' => $this->year, 'rating' => $this->rating, 'release_date' => $this->release_date, 'votes' => $this->votes]); $query->andFilterWhere(['like', 'title_id', $this->title_id])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'original_title', $this->original_title])->andFilterWhere(['like', 'mpaa_rating', $this->mpaa_rating])->andFilterWhere(['like', 'tagline', $this->tagline])->andFilterWhere(['like', 'plot', $this->plot])->andFilterWhere(['like', 'poster', $this->poster])->andFilterWhere(['like', 'runtime', $this->runtime])->andFilterWhere(['like', 'oscars', $this->oscars])->andFilterWhere(['like', 'awards', $this->awards])->andFilterWhere(['like', 'nominations', $this->nominations]); return $dataProvider; }
public function destroy($id) { $movie = Movie::find($id); $movie->delete(); return redirect()->back(); }