session()->get('country')); return redirect()->route('home.country', ['country' => $country]); } public function country(Request $request, $country) { $country_locale = CountryLocale::where('slug', $country)->first(); if (! is_null($country_locale)) { $request->session()->put('view_country_locale', $country_locale); $featured_posts = Post::select('posts.*') ->join('post_categories','posts.id','=', 'post_categories.post_id') ->join('categories','post_categories.category_id','=', 'categories.id') ->whereNotNull('post_categories.id') ->whereNotNull('categories.id') ->where('categories.country_locale_slug', $country_locale->slug) ->where('posts.featured', true) ->where('posts.status', 'publish') ->orderBy('posts.updated_at', 'desc') ->take(3) ->get(); $latest_posts = Post::select('posts.*') ->join('post_categories','posts.id','=', 'post_categories.post_id') ->join('categories','post_categories.category_id','=', 'categories.id') ->whereNotNull('post_categories.id') ->whereNotNull('categories.id') ->where('categories.country_locale_slug', $country_locale->slug) ->where('posts.featured', true) ->whereNotIn('posts.id', $featured_posts->pluck('id')->toArray()) ->where('posts.status', 'publish') ->orderBy('posts.updated_at', 'desc') ->distinct() ->take(20) ->get(); return view('front.country', compact('country_locale','featured_posts','latest_posts') ); } return redirect()->route('home.country', ['country' => config('platform.general.fallback_country_slug')]); } public function countryCategory(Request $request, $country, $category) { $country_locale = CountryLocale::where('slug', $country)->first(); if (is_null($country_locale)) { abort(404); } $category = Category::where('slug', $category)->where('enabled', true)->first(); if (is_null($category)) { abort(404); } return view('front.country_category', ['country_locale' => $country_locale, 'category' => $category]); } public function all(Request $request, $country) { $country_locale = CountryLocale::where('slug', $country)->first(); return view('front.country_all', ['country_locale' => $country_locale]); } public function posts(Request $request, $country) { return "{$country} : all posts"; } public function post(Request $request, $country, $post) { return "{$country} : {$post}"; } }