Ejemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Groups $group
  * @param type Group_assign_department $group_assign_department
  * @return type Response
  */
 public function destroy($id, Groups $group, Group_assign_department $group_assign_department)
 {
     $users = User::where('assign_group', '=', $id)->first();
     if ($users) {
         $user = '******';
         return redirect('groups')->with('fails', 'Group cannot Delete ' . $user);
     }
     $group_assign_department->where('group_id', $id)->delete();
     $groups = $group->whereId($id)->first();
     /* Check whether function success or not */
     try {
         $groups->delete();
         /* redirect to Index page with Success Message */
         return redirect('groups')->with('success', 'Group Deleted Successfully');
     } catch (Exception $e) {
         /* redirect to Index page with Fails Message */
         return redirect('groups')->with('fails', 'Groups cannot Create' . '<li>' . $e->errorInfo[2] . '</li>');
     }
 }
Ejemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  * @param type int $id
  * @param type Groups $group
  * @param type Group_assign_department $group_assign_department
  * @return type Response
  */
 public function destroy($id, Groups $group, Group_assign_department $group_assign_department)
 {
     try {
         $group_assign_department->where('group_id', $id)->delete();
         $groups = $group->whereId($id)->first();
         /* Check whether function success or not */
         if ($groups->delete() == true) {
             /* redirect to Index page with Success Message */
             return redirect('groups')->with('success', 'Group Deleted Successfully');
         } else {
             /* redirect to Index page with Fails Message */
             return redirect('groups')->with('fails', 'Group can not Delete');
         }
     } catch (Exception $e) {
         /* redirect to Index page with Fails Message */
         return redirect('groups')->with('fails', 'Groups can not Create');
     }
 }