Exemplo n.º 1
0
 /**
  * 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');
     }
 }
 /**
  * Update the specified resource in storage.
  * @param type int $id
  * @param type User $user
  * @param type AgentUpdate $request
  * @param type Assign_team_agent $team_assign_agent
  * @return type Response
  */
 public function update($id, User $user, AgentUpdate $request, Assign_team_agent $team_assign_agent)
 {
     try {
         $user = $user->whereId($id)->first();
         $daylight_save = $request->input('daylight_save');
         $limit_access = $request->input('limit_access');
         $directory_listing = $request->input('directory_listing');
         $vocation_mode = $request->input('vocation_mode');
         //==============================================
         $user->daylight_save = $daylight_save;
         $user->limit_access = $limit_access;
         $user->directory_listing = $directory_listing;
         $user->vocation_mode = $vocation_mode;
         //==============================================
         $table = $team_assign_agent->where('agent_id', $id);
         $table->delete();
         $requests = $request->input('team_id');
         foreach ($requests as $req) {
             DB::insert('insert into team_assign_agent (team_id, agent_id) values (?,?)', [$req, $id]);
         }
         //Todo For success and failure conditions
         $user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save();
         return redirect('agents')->with('success', 'Agent Updated sucessfully');
     } catch (Exception $e) {
         return redirect('agents')->with('fails', 'Agent did not update');
     }
 }
Exemplo n.º 3
0
 /**
  * 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>');
     }
 }