Files
productalert/app/Http/Controllers/Front/HomeController.php
2023-07-25 01:06:06 +08:00

35 lines
809 B
PHP

<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Stevebauman\Location\Facades\Location;
use App\Models\Category;
use App\Models\CountryLocale;
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']);
}
}