We have a restaurant page where the user can add his zip and we're showing the restaurants. We have solved this like this: web.php
Route::group(['prefix' => 'restaurants', 'namespace' => 'frontEnd', 'middleware'=>'checkzipcode'], function () {
Route::get('/', 'RestaurantController@showAllRestaurants');
Route::post('/', 'RestaurantController@showAllRestaurants');
Route::get('search','RestaurantController@searchRestaurant');
Route::post('typefilter','RestaurantController@productTypeFilter');
RestaurantController.php
public function showAllRestaurants(Request $request)
{
$getZipCode = session::get('zipcode',$request->zip_code);
if(!empty($getZipCode))
{
if(Auth::check()) {
$country_code = Auth::user()->country_code;
} else {
$country_code = Common::GetIPData()->iso_code;
}
// get all restaurant using zipcode
$all_restaurant = Restaurant::leftJoin('restaurant_delivery_areas','restaurant_delivery_areas.restaurant_id','=','restaurants.id')
->leftJoin('zip_codes','zip_codes.id','=','restaurant_delivery_areas.zip_code_id')
->leftJoin('restaurant_cuisines','restaurant_cuisines.restaurant_id','=','restaurants.id')
->where('restaurants.country_code',$country_code)
->where(function ($q) use($getZipCode) {
$q->where('restaurants.zip',$getZipCode)
->orWhere('zip_codes.postal_code',$getZipCode)
->where('restaurant_delivery_areas.is_active','=',1);
});
So now we would like to have just for each zip which is db a page like: test.com/restaurants/zip
Does anybody have a suggetion?