【发布时间】:2018-09-29 20:01:56
【问题描述】:
我们有一个餐厅页面,用户可以在其中添加他的 zip,我们会显示餐厅。我们已经解决了这个问题: 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);
});
所以现在我们只想为每个 zip 分贝一个页面,例如:test.com/restaurants/zip
有人有建议吗?
【问题讨论】:
-
康普伦多?没有
标签: php laravel session-variables