Add fallback route to catch all non existant routes

This commit is contained in:
David Bomba 2019-03-30 20:30:41 +11:00
parent 44c987fd41
commit e95558334e
3 changed files with 15 additions and 2 deletions

View File

@ -34,6 +34,16 @@ class BaseController extends Controller
}
/**
* Catch all fallback route
* for non-existant route
*/
public function notFound()
{
return response()->json([
'message' => 'Nothing to see here!'], 404);
}
protected function errorResponse($response, $httpErrorCode = 400)
{
$error['error'] = $response;

View File

@ -58,11 +58,11 @@ class ClientController extends BaseController
*/
public function index(ClientFilters $filters)
{
$clients = Client::filter($filters);
return $this->listResponse($clients);
// return response()->json($clients);
}
/**

View File

@ -65,4 +65,7 @@ Route::group(['middleware' => ['db','api_secret_check','token_auth']], function
Route::get('settings', 'SettingsController@index')->name('user.settings');
});
});
Route::fallback('BaseController@notFound');