/** * Display a listing of the resource. * * @return Response */ public function index($cookbook = '*') { $languages = Input::get('lang', ['nl', 'uk']); $search = new RecipeSearch(); $search->setCookbook($cookbook); $recipes = $search->buildQuery()->select('tracking_nr', 'title', 'category', 'cookbook', 'language')->whereIn('language', $languages)->orderBy('created_at', 'desc'); $count = $recipes->count(); $url_params = array_merge($search->getParams(), ['lang[]' => $languages]); $recipes = $recipes->paginate(static::$per_page)->appends($url_params); Session::flash('return_url', route('recipes.index', $search->getParams())); $available_languages = $search->buildQuery()->select('language')->distinct()->orderBy('language', 'desc')->get()->lists('language')->all(); return view('recipes.index')->with('recipes', $recipes)->with('count', $count)->with('chosen_languages', $languages)->with('available_languages', $available_languages)->with('categories', Recipe::categories($languages))->with('hide_cookbooks', $search->shouldHideCookbooks())->with('params', $search->getParams()); }