/** * @api {get} /tasks/:slug/doers Get Task Doers * @apiGroup Tasks * @apiDescription Returns a list of users that have a task on their to do list. * * @param Task $task * * @return \Illuminate\Http\Response */ public function index(Task $task) { $earners = $task->doers()->orderBy('pivot_createdAt', 'DESC')->withPivot('id', 'likeCount'); $paginator = $earners->paginate($this->getResultsPerPage()); $array = $this->paginatorToArray($paginator, 'users'); if ($this->user) { foreach ($array['users'] as &$user) { $user['pivot']['liked'] = $this->user->likesToDo($user['pivot']['id']); } } return $this->response($array); }
/** * Get a query for the all the users that have a Task on their To Do List. * * @param Task $task * * @return Builder */ public function getTaskDoers(Task $task) { return $task->doers()->orderBy('pivot_createdAt', 'DESC')->withPivot('id', 'likeCount'); }