@@ -138,19 +138,34 @@ public function edit(Request $request, $id)
138138
139139 public function update (Request $ request , $ id )
140140 {
141- try {
142- $ repo = new Pack ;
143- $ repo ->update ($ id , $ request ->except ([
144- '_token '
145- ]));
146- Alert::success ('Service pack has been successfully updated. ' )->flash ();
147- } catch (DisplayValidationException $ ex ) {
148- return redirect ()->route ('admin.services.packs.edit ' , $ id )->withErrors (json_decode ($ ex ->getMessage ()))->withInput ();
149- } catch (\Exception $ ex ) {
150- Log::error ($ ex );
151- Alert::danger ('An error occured while attempting to add edit this pack. ' )->flash ();
141+ if (!is_null ($ request ->input ('action_delete ' ))) {
142+ try {
143+ $ repo = new Pack ;
144+ $ repo ->delete ($ id );
145+ Alert::success ('The requested service pack has been deleted from the system. ' )->flash ();
146+ return redirect ()->route ('admin.services.packs ' );
147+ } catch (DisplayException $ ex ) {
148+ Alert::danger ($ ex ->getMessage ())->flash ();
149+ } catch (\Exception $ ex ) {
150+ Log::error ($ ex );
151+ Alert::danger ('An error occured while attempting to delete this pack. ' )->flash ();
152+ }
153+ return redirect ()->route ('admin.services.packs.edit ' , $ id );
154+ } else {
155+ try {
156+ $ repo = new Pack ;
157+ $ repo ->update ($ id , $ request ->except ([
158+ '_token '
159+ ]));
160+ Alert::success ('Service pack has been successfully updated. ' )->flash ();
161+ } catch (DisplayValidationException $ ex ) {
162+ return redirect ()->route ('admin.services.packs.edit ' , $ id )->withErrors (json_decode ($ ex ->getMessage ()))->withInput ();
163+ } catch (\Exception $ ex ) {
164+ Log::error ($ ex );
165+ Alert::danger ('An error occured while attempting to add edit this pack. ' )->flash ();
166+ }
167+ return redirect ()->route ('admin.services.packs.edit ' , $ id );
152168 }
153- return redirect ()->route ('admin.services.packs.edit ' , $ id );
154169 }
155170
156171 public function export (Request $ request , $ id , $ files = false )
0 commit comments