/** * Remove the specified resource from storage. * @param type int $id * @param type Teams $team * @param type Assign_team_agent $assign_team_agent * @return type Response */ public function destroy($id, Teams $team, Assign_team_agent $assign_team_agent) { try { $assign_team_agent->where('team_id', $id)->delete(); $teams = $team->whereId($id)->first(); /* Check whether function success or not */ if ($teams->delete() == true) { /* redirect to Index page with Success Message */ return redirect('teams')->with('success', 'Teams Deleted Successfully'); } else { /* redirect to Index page with Fails Message */ return redirect('teams')->with('fails', 'Teams can not Delete'); } } catch (Exception $e) { /* redirect to Index page with Fails Message */ return redirect('teams')->with('fails', 'Teams can not Delete'); } }
/** * Remove the specified resource from storage. * @param type int $id * @param type Teams $team * @param type Assign_team_agent $assign_team_agent * @return type Response */ public function destroy($id, Teams $team, Assign_team_agent $assign_team_agent) { try { $assign_team_agent->where('team_id', $id)->delete(); $teams = $team->whereId($id)->first(); $tickets = DB::table('tickets')->where('team_id', '=', $id)->update(['team_id' => null]); /* Check whether function success or not */ $teams->delete(); /* redirect to Index page with Success Message */ return redirect('teams')->with('success', 'Teams Deleted Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ return redirect('teams')->with('fails', 'Teams can not Delete' . '<li>' . $e->errorInfo[2] . '</li>'); } }