public function updateAction($id, Request $request) { $collabs = ""; $model = new Action(); $input = $request->all(); $actionComment = new ActionComments(); $comments = $actionComment->getComments($id); $action = Action::findOrFail($id); $users = array(); $roster = DB::table('rosters')->select('user_ID')->where('group_ID', '=', $action->group)->get(); foreach ($roster as $x) { array_push($users, $x->user_ID); } $groupLead = User::find(Group::find($action->group)->user_ID)->id; if (Auth::check()) { $user = User::find(Auth::id()); $permission = $user->hasRole('bpLead'); } else { $permission = false; } $businessplan = $model->getBpIdFromAction($id); if (array_key_exists('collaborators-groups', $input)) { foreach ($input['collaborators-groups'] as $x) { $collabs .= Group::find($x)->name; $collabs .= ", "; } } if (array_key_exists('collaborators-users', $input)) { foreach ($input['collaborators-users'] as $x) { $collabs .= User::find($x)->name; $collabs .= ", "; } } $collabs = rtrim($collabs, ", "); $input['collaborators'] = $collabs; $action->update($input); $tasks = Task::all()->where('action_id', $id); return view('action', compact('comments', 'action', 'tasks', 'users', 'permission', 'groupLead', 'businessplan')); }
public function getComments($action_id) { $comments = ActionComments::All(); $comment = $comments->where('action_ID', $action_id); return $comment; }