Files
productalert/app/Http/Controllers/Front/HomeController.php

30 lines
776 B
PHP

<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\CountryLocale;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index(Request $request)
{
return redirect()->route('home.country', ['country' => 'my']);
}
public function country(Request $request, $country)
{
$country = CountryLocale::where('slug', $country)->first();
if (! is_null($country)) {
$categories = Category::where('country_locale_id', $country->id)->get();
return view('front.country', ['categories' => $categories, 'country' => $country]);
}
return redirect()->route('home.country', ['country' => 'my']);
}
}