/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // Start transaction! \DB::beginTransaction(); try { $HTMLControl = HTMLControl::find($id); if ($HTMLControl) { $this->withdraw($HTMLControl); //HTMLControl_I10n $HTMLControlI10ns = HTMLControl_I10N::where('i18n_id', '=', $id)->get(); if ($HTMLControlI10ns) { foreach ($HTMLControlI10ns as $HTMLControlI10n) { $this->withdraw($HTMLControlI10n); } } // Commit \DB::commit(); return Response::json(['result' => 'OK']); } } catch (\ValidationException $e) { // Rollback and then redirect DB::rollback(); App::abort(404); } // Rollback DB::rollback(); }