/** * show all torrent or one based on search. * * @param Request $request * * @return \Illuminate\View\View */ public function index(Request $request) { //$output = \Tmdb::getSearchApi()->searchMovies('saw',array('language' => 'fr')); $perPage = 2; $input = $request->input('q'); $tags = ''; if ($request->input('tags') != '') { $tags = explode(',', $request->input('tags')); } if ($input && !$tags) { $rows = Movie::title($input)->sortAndPaginate($perPage); } elseif ($tags) { $rows = Movie::title($input)->tags($tags)->sortAndPaginate($perPage); } else { $rows = Movie::sortAndPaginate($perPage); } if (!$tags) { $tags = []; } $table = \Table::create($rows, ['test']); $table->addColumn('title', 'Nom', function ($torrent) { return $torrent->title; }); $table->addColumn('created_at', 'Ajouté', function ($torrent) { return $torrent->created_at->diffForHumans(); }); return view('torrents.index', ['table' => $table, 'input' => $input, 'tags' => implode(',', $tags)]); }