From 74f32c92807bf5c90626c71062721913b7d20ddc Mon Sep 17 00:00:00 2001 From: Manish Verma Date: Wed, 28 Dec 2016 19:19:49 +0530 Subject: [PATCH] Bug-fix-patch-15.1 # Assigning agent to team if s/he's been choosen as team leader while creating a new team. --- .../Admin/helpdesk/TeamController.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/helpdesk/TeamController.php b/app/Http/Controllers/Admin/helpdesk/TeamController.php index eef54a4ff..6b65c4988 100644 --- a/app/Http/Controllers/Admin/helpdesk/TeamController.php +++ b/app/Http/Controllers/Admin/helpdesk/TeamController.php @@ -86,15 +86,24 @@ class TeamController extends Controller */ public function store(Teams $team, TeamRequest $request) { - if ($request->team_lead) { - $team_lead = $request->team_lead; - } else { - $team_lead = null; - } - $team->team_lead = $team_lead; try { /* Check whether function success or not */ $team->fill($request->except('team_lead'))->save(); + $team_update = Teams::find($team->id); + if ($request->team_lead) { + $team_lead = $request->team_lead; + $team_update->update([ + 'team_lead' => $team_lead + ]); + Assign_team_agent::create([ + 'team_id' => $team_update->id, + 'agent_id' => $team_lead + ]); + } else { + $team_lead = null; + } + + /* redirect to Index page with Success Message */ return redirect('teams')->with('success', Lang::get('lang.teams_created_successfully')); } catch (Exception $e) {