diff --git a/app/Http/Controllers/Frontend/ProfileController.php b/app/Http/Controllers/Frontend/ProfileController.php index f8f24429..2ef5f421 100644 --- a/app/Http/Controllers/Frontend/ProfileController.php +++ b/app/Http/Controllers/Frontend/ProfileController.php @@ -18,10 +18,8 @@ use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; use Intervention\Image\Facades\Image; use Laracasts\Flash\Flash; +use Nwidart\Modules\Facades\Module; -/** - * Class ProfileController - */ class ProfileController extends Controller { private $airlineRepo; @@ -45,6 +43,21 @@ class ProfileController extends Controller $this->userRepo = $userRepo; } + /** + * Return whether the vmsACARS module is enabled or not + */ + private function acarsEnabled(): bool + { + // Is the ACARS module enabled? + $acars_enabled = false; + $acars = Module::find('VMSACARS'); + if ($acars) { + $acars_enabled = $acars->isEnabled(); + } + + return $acars_enabled; + } + /** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ @@ -57,6 +70,7 @@ class ProfileController extends Controller } return view('profile.index', [ + 'acars' => $this->acarsEnabled(), 'user' => Auth::user(), 'airports' => $airports, ]); @@ -119,7 +133,7 @@ class ProfileController extends Controller * * @throws \Prettus\Validator\Exceptions\ValidatorException * - * @return $this + * @return mixed */ public function update(Request $request) { @@ -200,4 +214,24 @@ class ProfileController extends Controller return redirect(route('frontend.profile.index')); } + + /** + * Generate the ACARS config and send it to download + * + * @param \Illuminate\Http\Request $request + * + * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response + */ + public function acars(Request $request) + { + $user = Auth::user(); + $config = view('system.acars.config', ['user' => $user])->render(); + + return response($config)->withHeaders([ + 'Content-Type' => 'text/xml', + 'Content-Length' => strlen($config), + 'Cache-Control' => 'no-store, no-cache', + 'Content-Disposition' => 'attachment; filename="settings.xml', + ]); + } } diff --git a/app/Http/Routes/web.php b/app/Http/Routes/web.php index b7a63c1e..2c9782da 100755 --- a/app/Http/Routes/web.php +++ b/app/Http/Routes/web.php @@ -48,8 +48,9 @@ Route::group([ Route::get('pireps/fares', 'PirepController@fares'); Route::post('pireps/{id}/submit', 'PirepController@submit')->name('pireps.submit'); - Route::get('profile/regen_apikey', 'ProfileController@regen_apikey') - ->name('profile.regen_apikey'); + Route::get('profile/acars', 'ProfileController@acars')->name('profile.acars'); + Route::get('profile/regen_apikey', 'ProfileController@regen_apikey')->name('profile.regen_apikey'); + Route::resource('profile', 'ProfileController'); }); diff --git a/resources/views/layouts/default/profile/index.blade.php b/resources/views/layouts/default/profile/index.blade.php index 1164844b..3f92f2af 100644 --- a/resources/views/layouts/default/profile/index.blade.php +++ b/resources/views/layouts/default/profile/index.blade.php @@ -94,6 +94,11 @@
+ @if ($acars) + ACARS Config +   + @endif @lang('profile.newapikey')   diff --git a/resources/views/system/acars/config.blade.php b/resources/views/system/acars/config.blade.php new file mode 100644 index 00000000..44e8d026 --- /dev/null +++ b/resources/views/system/acars/config.blade.php @@ -0,0 +1,4 @@ + + {{ config('app.url') }} + {{ $user->api_key }} +