From d5620294e21f1fee111a08b2849c70795b4c71d9 Mon Sep 17 00:00:00 2001 From: cp6 Date: Tue, 22 Feb 2022 13:38:44 +1100 Subject: [PATCH] Added IP addresses API Added IP addresses API --- app/Http/Controllers/ApiController.php | 15 +++++++++++++++ routes/api.php | 3 +++ 2 files changed, 18 insertions(+) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 6dcf9b9..a8d8fa9 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\IPs; use App\Models\Labels; use App\Models\NetworkSpeed; use App\Models\OS; @@ -236,6 +237,20 @@ class ApiController extends Controller return response($os, 200); } + protected function getAllIPs() + { + $ip = IPs::all()->toJson(JSON_PRETTY_PRINT); + return response($ip, 200); + } + + protected function getIP($id) + { + $ip = DB::table('ips as i') + ->where('i.id', '=', $id) + ->get()->toJson(JSON_PRETTY_PRINT); + return response($ip, 200); + } + public function getAllProvidersTable(Request $request) { if ($request->ajax()) { diff --git a/routes/api.php b/routes/api.php index c0d6fa8..cfbad94 100644 --- a/routes/api.php +++ b/routes/api.php @@ -28,6 +28,9 @@ Route::middleware('auth:api')->get('domains/{id}', 'App\Http\Controllers\ApiCont Route::middleware('auth:api')->get('servers', 'App\Http\Controllers\ApiController@getAllServers'); Route::middleware('auth:api')->get('servers/{id}', 'App\Http\Controllers\ApiController@getServer'); +Route::middleware('auth:api')->get('IPs/', 'App\Http\Controllers\ApiController@getAllIPs'); +Route::middleware('auth:api')->get('IPs/{id}', 'App\Http\Controllers\ApiController@getIP'); + Route::middleware('auth:api')->get('labels/', 'App\Http\Controllers\ApiController@getAllLabels'); Route::middleware('auth:api')->get('labels/{id}', 'App\Http\Controllers\ApiController@getLabel');