Ejemplo n.º 1
0
 /**
  * Remove the specified form categories from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $form_cat = \FormCategory::findOrFail($id);
     if ($form_cat->forms->count() > 0) {
         return \Redirect::to('backend/form-categories')->with('error_message', trans('error_messages.form_cat_delete_assoc'));
     }
     if ($form_cat && $form_cat->delete()) {
         if (\Request::ajax()) {
             return \Response::json(trans('success_messages.form_cat_delete'), 200);
         }
         return \Redirect::to('backend/form-categories')->with('success_message', trans('success_messages.form_cat_delete'));
     } else {
         if (\Request::ajax()) {
             return \Response::json('The form category wasn\'t deleted.', 400);
         }
         return \Redirect::to('backend/form-categories')->with('error_message', trans('error_messages.form_cat_delete'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Remove the specified form categories from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $form_cat = \FormCategory::findOrFail($id);
     if ($form_cat->forms->count() > 0) {
         return \Redirect::to('backend/form-categories')->with('error_message', 'The form category can\'t be deleted because one or more form belong to this category. <br> Either change the form category in those form(s) or delete the form(s) first to delete this form.');
     }
     if ($form_cat && $form_cat->delete()) {
         if (\Request::ajax()) {
             return \Response::json('The form category was deleted.', 200);
         }
         return \Redirect::to('backend/form-categories')->with('success_message', 'The form category was deleted.');
     } else {
         if (\Request::ajax()) {
             return \Response::json('The form category wasn\'t deleted.', 400);
         }
         return \Redirect::to('backend/form-categories')->with('error_message', 'The form category was not deleted.');
     }
 }