public function getAssigntarget() { $employee = Employee::all(); $categories = Event::all(); $userdetails = User::all(); $targets = Targetassign::all(); $deals = Deal::all(); $userData = array(); $key = 0; foreach ($targets as $target) { $achieved = 0; $userData[$key]['eventcode'] = $target->Eventcode; $userData[$key]['event'] = $target->Eventname; $userData[$key]['employee'] = $target->Employeeid; $userData[$key]['targetVal'] = $target->Targetvalue; foreach ($deals as $deal) { if ($target->Eventcode == $deal->Eventcode && $target->Employeeid == $deal->Empid) { $achieved = $achieved + $deal->Dealvalue; } } $userData[$key]['achieved'] = $achieved; $userData[$key]['variance'] = $achieved - $target->Targetvalue; $userData[$key]['cur'] = $target->Currency; $key++; } return View('approval/assigntarget')->with(array('categories' => $categories, 'employee' => $employee, 'userdata' => $userData, 'targets' => $targets, 'eventtable' => $categories)); }