/** * @api {get} /stickers/:slug/doers Get Sticker Doers * @apiGroup Stickers * @apiDescription Returns a list of users that have a sticker on their to do list. * * @param Sticker $sticker * * @return \Illuminate\Http\Response */ public function index(Sticker $sticker) { $earners = $sticker->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 all the Users that have a Sticker on their To Do List. * * @param Sticker $sticker * * @return Builder */ public function getStickerDoers(Sticker $sticker) { return $sticker->doers()->orderBy('pivot_createdAt', 'DESC')->withPivot('id', 'likeCount'); }