dimanche 14 octobre 2018

Laravel set Array in Route

Hello Stackoverflow Community

After some research we decide to ask you for the solution.

We would like to have a link with a defined array. The goal would be to have a link as: https://ift.tt/2OWwwEN

An then we would just like to see to all restaurant with the particular cuisine. The filter is currently working on the website with a check-box.

Currenty Router:

 Route::group(['prefix' => 'restaurants', 'namespace' => 'frontEnd', 'middleware'=>'checkzipcode'], function () {
        Route::get('/', 'RestaurantController@showAllRestaurants');
        Route::post('/', 'RestaurantController@showAllRestaurants');
    });

Controller:

if(request('cusineName')) {
            if(is_array(request('cusineName'))) {
                $cusineName = request('cusineName');

            } else {
                $cusineName = (explode(",",request('cusineName')));
            }
            $all_restaurant = $all_restaurant->whereIn('restaurant_cuisines.type_cuisine_id',$cusineName);
        }

We was thinking to set the array into the controller, or any other suggetions?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire