Add (routes): All routes possible
Add (pages): home country page
This commit is contained in:
@@ -7,23 +7,45 @@
|
||||
use App\Models\CountryLocale;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Stevebauman\Location\Facades\Location;
|
||||
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return redirect()->route('home.country', ['country' => 'my']);
|
||||
$country = strtolower($request->session()->get('country'));
|
||||
|
||||
return redirect()->route('home.country', ['country' => $country]);
|
||||
}
|
||||
|
||||
public function country(Request $request, $country)
|
||||
{
|
||||
$country = CountryLocale::where('slug', $country)->first();
|
||||
$country_locale = CountryLocale::where('slug', $country)->first();
|
||||
|
||||
if (! is_null($country)) {
|
||||
$categories = Category::where('country_locale_id', $country->id)->get();
|
||||
$categories = Category::where('country_locale_id', $country_locale->id)->get();
|
||||
|
||||
return view('front.country', ['categories' => $categories, 'country' => $country]);
|
||||
$request->session()->put('view_country_locale', $country_locale);
|
||||
|
||||
return view('front.country', ['categories' => $categories, 'country_locale' => $country_locale]);
|
||||
}
|
||||
|
||||
return redirect()->route('home.country', ['country' => 'my']);
|
||||
return redirect()->route('home.country', ['country' => config('platform.general.fallback_country_slug')]);
|
||||
}
|
||||
|
||||
public function countryCategory(Request $request, $country, $category)
|
||||
{
|
||||
return "{$country} : {$category}";
|
||||
}
|
||||
|
||||
public function posts(Request $request, $country)
|
||||
{
|
||||
return "{$country} : all posts";
|
||||
}
|
||||
|
||||
public function post(Request $request, $country, $post)
|
||||
{
|
||||
return "{$country} : {$post}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user