63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Front;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Category;
|
|
use App\Models\CountryLocale;
|
|
use Illuminate\Http\Request;
|
|
|
|
use Stevebauman\Location\Facades\Location;
|
|
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$country = strtolower($request->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);
|
|
|
|
return view('front.country', ['country_locale' => $country_locale]);
|
|
}
|
|
|
|
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 posts(Request $request, $country)
|
|
{
|
|
return "{$country} : all posts";
|
|
}
|
|
|
|
public function post(Request $request, $country, $post)
|
|
{
|
|
return "{$country} : {$post}";
|
|
}
|
|
}
|