SimBrief : Generate New Briefing (#986)

* Add SB Briefing Removal Route

Route will be called from simbrief.briefing.blade

* SimBrief Controller and Briefing Blade Update

Added the remove function to controller, which removes the simbrief ofp if no pirep_id is present, else it just nulls the flight_id for to be able to create a new SB pack

Also added the button to blade for it to work

* Style Fix

love styleci
pull/988/head
B.Fatih KOZ 4 years ago committed by GitHub
parent ad8b8e8945
commit 984c1e0cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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([

@ -3,7 +3,7 @@
@section('content')
<div class="row">
<div class="col-sm-9">
<div class="col-sm-6">
<h2>{{ $simbrief->xml->general->icao_airline }}{{ $simbrief->xml->general->flight_number }}
: {{ $simbrief->xml->origin->icao_code }} to {{ $simbrief->xml->destination->icao_code }}</h2>
</div>
@ -14,6 +14,11 @@
href="{{ url(route('frontend.simbrief.prefile', [$simbrief->id])) }}">Prefile PIREP</a>
@endif
</div>
<div class="col-sm-3">
<a class="btn btn-primary pull-right btn-lg"
style="margin-top: -10px;margin-bottom: 5px"
href="{{ url(route('frontend.simbrief.remove', [$simbrief->id])) }}">Generate New OFP</a>
</div>
</div>
<div class="row">

Loading…
Cancel
Save