laravel check api.php route code example
Example 1: laravel check if api request
if (Request::wantsJson()) {
// return JSON-formatted response
} else {
// return HTML response
}
Example 2: laravel api routes
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);