Add (country category)

This commit is contained in:
2023-07-26 11:15:28 +08:00
parent 2c42553599
commit 9ebecd7a8f
4 changed files with 112 additions and 6 deletions

View File

@@ -23,12 +23,11 @@ public function country(Request $request, $country)
{
$country_locale = CountryLocale::where('slug', $country)->first();
if (! is_null($country)) {
$categories = Category::where('country_locale_id', $country_locale->id)->get();
if (! is_null($country_locale)) {
$request->session()->put('view_country_locale', $country_locale);
return view('front.country', ['categories' => $categories, 'country_locale' => $country_locale]);
return view('front.country', ['country_locale' => $country_locale]);
}
return redirect()->route('home.country', ['country' => config('platform.general.fallback_country_slug')]);
@@ -36,7 +35,19 @@ public function country(Request $request, $country)
public function countryCategory(Request $request, $country, $category)
{
return "{$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 posts(Request $request, $country)