I have some routes in my Laravel application (many routes)
I want to add new functionality, to return all data in JSON format. Now data are just views .
/route1/options /route2/options
etc
i want to have
/json/route1/options /json/route2/options
so, if any my existent route gets a prefix /json then data should be returned with JSON .
My routes looks like normal routes in Laravel
Route::get('user/{id}', function($id) {
$user = ....
return view('userprofile', $user);
});
How to change this to know that json format is requested? should it be separate routing group where each route is described again?