From 479d66ee6889a886ae3a41158cb456eab5a9bfa7 Mon Sep 17 00:00:00 2001 From: cp6 Date: Sun, 20 Feb 2022 00:19:47 +1100 Subject: [PATCH] Added OS to API Added OS to API --- README.md | 5 +++++ app/Http/Controllers/ApiController.php | 15 +++++++++++++++ routes/api.php | 3 +++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 682874a..7bc3693 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ removed. * Misc services. * DNS CRUD. * Reseller hosting. +* Added Operating systems to DB, Deleting and creating them now possible. * Make servers displayable public with config options to hide certain values. * Vue JS used where possible. * Datatables used on large tables (Locations, labels, and providers). @@ -110,6 +111,10 @@ All API requests must be appended with `api/` e.g `mydomain.com/api/servers/gYk8 `networkSpeeds/{id}` +`os/` + +`os/{id}` + `pricing/` `pricing/{id}` diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index cc7326b..6dcf9b9 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\Labels; use App\Models\NetworkSpeed; +use App\Models\OS; use App\Models\Pricing; use App\Models\Providers; use App\Models\Server; @@ -221,6 +222,20 @@ class ApiController extends Controller return response($settings, 200); } + protected function getAllOs() + { + $os = OS::all()->toJson(JSON_PRETTY_PRINT); + return response($os, 200); + } + + protected function getOs($id) + { + $os = DB::table('os as o') + ->where('o.id', '=', $id) + ->get()->toJson(JSON_PRETTY_PRINT); + return response($os, 200); + } + public function getAllProvidersTable(Request $request) { if ($request->ajax()) { diff --git a/routes/api.php b/routes/api.php index 85f771b..c0d6fa8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -40,6 +40,9 @@ Route::middleware('auth:api')->get('misc/{id}', 'App\Http\Controllers\ApiControl Route::middleware('auth:api')->get('networkSpeeds/', 'App\Http\Controllers\ApiController@getAllNetworkSpeeds'); Route::middleware('auth:api')->get('networkSpeeds/{id}', 'App\Http\Controllers\ApiController@getNetworkSpeeds'); +Route::middleware('auth:api')->get('os/', 'App\Http\Controllers\ApiController@getAllOs'); +Route::middleware('auth:api')->get('os/{id}', 'App\Http\Controllers\ApiController@getOs'); + Route::middleware('auth:api')->get('pricing/', 'App\Http\Controllers\ApiController@getAllPricing'); Route::middleware('auth:api')->get('pricing/{id}', 'App\Http\Controllers\ApiController@getPricing');