public function getMemberHome() { date_default_timezone_set(config::$timezone); $today = date("Y-m-d"); // Holding watched movies id $watchedMovies = Order::where('member_id', '=', Session::get('member_id'))->select('movie_id')->get()->toArray(); // Building query whare id = ? or id = ? so on $ids = 'id = ?'; for ($i = 1; $i < count($watchedMovies); $i++) { $ids .= ' or id = ?'; } $memberWatchedMovies = Movie::orWhereRaw($ids, $watchedMovies)->get(); return View::make('adminArea/home/member-dashboard')->with('newMovies', Movie::orderBy('id', 'desc')->get()->take(20))->with('watchedMovies', $memberWatchedMovies); }
/** * This function responses to the * post request of the /admin/movie/action * then checked which button is pressed in the * form of movie.view.blade.php of the * route /admin/movie */ public function postAction() { // Holding checked row value from movie table $id = Input::get('checked'); /** * Redirected route if Edit button is pressed */ if (Input::has('Edit')) { return Redirect::route('movie-edit-get', $id); } /** * Redirected route if Details button is pressed */ if (Input::has('Details')) { return Redirect::route('movie-details-get', $id); } /** * Redirected route if Print button is pressed */ if (Input::has('Print')) { $parameterr = array(); $parameter['movies'] = Movie::orderBy('id', 'desc')->get(); $pdf = PDF::loadView('reports.movie.getAllMovies', $parameter)->setPaper('a4')->setOrientation(config::$MOVIE_REPORT_ORIENTATION)->setWarnings(false); return $pdf->stream('movies.pdf'); } /** * If Delete button is pressed * destroy function finds movie by id * and deletes the movie from movie table */ if (Input::has('Delete')) { foreach ($id as $movieId) { $movie = Movie::find($movieId); $movie->delete(); } return Redirect::route('movie-get', 1); } }
/** * Laravel sends content to the frontend as JSON * * @return Response */ public function index() { return Response::json(Movie::orderBy('id', 'desc')->get()); }
/** * This function responses to * the get request of /member/movie * and show all movie as list */ public function getMovie() { return View::make('adminArea.movie.view')->with('movies', Movie::orderBy('id', 'desc')->get()); }