public function userEntries($user = null) { if ($user === null) { return []; } return json_collection(UserContestEntry::where(['contest_id' => $this->id, 'user_id' => $user->user_id])->get(), new UserContestEntryTransformer()); }