From 2d73cb00127daefe73ba1ca4dc4164758e9818b9 Mon Sep 17 00:00:00 2001 From: K Miyano Date: Thu, 30 Apr 2020 01:41:18 +0900 Subject: [PATCH] Move API fallback to BasicApiController --- app/Http/Controllers/Api/v1/BasicApiController.php | 8 ++++++++ routes/api.php | 8 +------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/v1/BasicApiController.php b/app/Http/Controllers/Api/v1/BasicApiController.php index 5059e0e..8e02d79 100644 --- a/app/Http/Controllers/Api/v1/BasicApiController.php +++ b/app/Http/Controllers/Api/v1/BasicApiController.php @@ -16,4 +16,12 @@ public function status(){ $return['birthday'] = getIdolByBirthdate(); return response()->json($return); } + + public function routeFallback(){ + return response()->json(['error' => [ + 'status' => 404, + 'error' => 'Not Found', + 'message' => 'There is nothing here.' + ]],404); + } } diff --git a/routes/api.php b/routes/api.php index 5638783..c744a50 100644 --- a/routes/api.php +++ b/routes/api.php @@ -19,12 +19,6 @@ Route::get('status','BasicApiController@status'); }); - Route::fallback(function (){ - return response()->json(['error' => [ - 'status' => 404, - 'error' => 'Not Found', - 'message' => 'There is nothing here.' - ]],404); - }); + Route::fallback('Api\v1\BasicApiController@routeFallback'); });