From d160dcbd0b7143ada2a90c48b442e6b83303ebc4 Mon Sep 17 00:00:00 2001 From: Henry Whitaker Date: Fri, 24 Apr 2020 18:20:12 +0100 Subject: [PATCH] Added changelog API method --- app/Http/Controllers/UpdateController.php | 17 +++++++++++++++++ routes/api.php | 2 ++ 2 files changed, 19 insertions(+) diff --git a/app/Http/Controllers/UpdateController.php b/app/Http/Controllers/UpdateController.php index bc2b132c..b5c6ad4f 100644 --- a/app/Http/Controllers/UpdateController.php +++ b/app/Http/Controllers/UpdateController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use Exception; use Updater; use Illuminate\Http\Request; @@ -58,4 +59,20 @@ class UpdateController extends Controller 'success' => $cp, ], 200); } + + public function changelog() + { + $url = base_path() . '/changelog.json'; + + try { + $changelog = json_decode(file_get_contents($url), true); + } catch(Exception $e) { + $changelog = []; + } + + return response()->json([ + 'method' => 'get changelog', + 'data' => $changelog + ], 200); + } } diff --git a/routes/api.php b/routes/api.php index cf4ecbda..73d4acde 100644 --- a/routes/api.php +++ b/routes/api.php @@ -42,6 +42,8 @@ Route::group([ 'middleware' => 'api', 'prefix' => 'update', ], function () { + Route::get('changelog', 'UpdateController@changelog') + ->name('update.changelog'); Route::get('check', 'UpdateController@checkForUpdate') ->name('update.check'); Route::get('download', 'UpdateController@downloadUpdate')