diff --git a/app/Http/Controllers/Frontend/SimBriefController.php b/app/Http/Controllers/Frontend/SimBriefController.php index 7b155db7..580d29e8 100644 --- a/app/Http/Controllers/Frontend/SimBriefController.php +++ b/app/Http/Controllers/Frontend/SimBriefController.php @@ -80,6 +80,29 @@ class SimBriefController ]); } + /** + * Remove the flight_id from the SimBrief Briefing (to a create a new one) + * or if no pirep_id is attached to the briefing delete it completely + * + * @param \Illuminate\Http\Request $request + * + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + */ + public function remove(Request $request) + { + $sb_pack = SimBrief::find($request->id); + if ($sb_pack) { + if (!$sb_pack->pirep_id) { + $sb_pack->delete(); + } else { + $sb_pack->flight_id = null; + $sb_pack->save(); + } + } + + return redirect(route('frontend.flights.index')); + } + /** * Create a prefile of this PIREP with a given OFP. Then redirect the * user to the newly prefiled PIREP diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 6ba793d3..2cdd142c 100755 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -147,6 +147,7 @@ class RouteServiceProvider extends ServiceProvider Route::get('simbrief/{id}', 'SimBriefController@briefing')->name('simbrief.briefing'); Route::get('simbrief/{id}/prefile', 'SimBriefController@prefile')->name('simbrief.prefile'); Route::get('simbrief/{id}/cancel', 'SimBriefController@cancel')->name('simbrief.cancel'); + Route::get('simbrief/{id}/remove', 'SimBriefController@remove')->name('simbrief.remove'); }); Route::group([ diff --git a/resources/views/layouts/default/flights/simbrief_briefing.blade.php b/resources/views/layouts/default/flights/simbrief_briefing.blade.php index 82c6141e..f88c97bf 100644 --- a/resources/views/layouts/default/flights/simbrief_briefing.blade.php +++ b/resources/views/layouts/default/flights/simbrief_briefing.blade.php @@ -3,7 +3,7 @@ @section('content')