Commit 7adbee5384863b11f6ba05ec22a3d7fe17608153
1 parent
7dff14cf4c
Exists in
master
and in
4 other branches
Check if OD, MLTD relations exist before query
Showing 2 changed files with 13 additions and 0 deletions
api/app/Http/Controllers/V1/Components/MltdController.php
View file @
7adbee5
... | ... | @@ -82,6 +82,12 @@ |
82 | 82 | |
83 | 83 | public function count(Request $request) |
84 | 84 | { |
85 | + if (!Schema::hasTable('mltd')) { | |
86 | + return response()->json([ | |
87 | + 'error' => 'Relation for MLTD component does not exist' | |
88 | + ], 503); | |
89 | + } | |
90 | + | |
85 | 91 | if ($request->has('start')) { |
86 | 92 | $start = Carbon::parse($request->get('start')); |
87 | 93 | } else { |
api/app/Http/Controllers/V1/Components/OdController.php
View file @
7adbee5
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | use Illuminate\Http\Request; |
8 | 8 | use Illuminate\Support\Facades\DB; |
9 | 9 | use Illuminate\Support\Facades\Http; |
10 | +use Illuminate\Support\Facades\Schema; | |
10 | 11 | |
11 | 12 | class OdController extends Controller |
12 | 13 | { |
... | ... | @@ -85,6 +86,12 @@ |
85 | 86 | |
86 | 87 | public function count(Request $request) |
87 | 88 | { |
89 | + if (!Schema::hasTable('od')) { | |
90 | + return response()->json([ | |
91 | + 'error' => 'Relation for OD component does not exist' | |
92 | + ], 503); | |
93 | + } | |
94 | + | |
88 | 95 | if ($request->has('start')) { |
89 | 96 | $start = Carbon::parse($request->get('start')); |
90 | 97 | } else { |