public function getVerify() { $this->beforeFilter('admin'); $userQuery = UserMeta::where('meta_key', 'verify'); if (Input::get('status')) { $userQuery->where('meta_value', Input::get('status')); } $requests = $userQuery->with('user')->get(); return Response::json($requests); }
/** * getValidSponsors. * * @todo I'm not sure what exactly this does at first glance */ public function getValidSponsors() { $collection = new Collection(); $groups = GroupMember::where('user_id', '=', $this->id)->whereIn('role', array(Group::ROLE_EDITOR, Group::ROLE_OWNER))->get(); foreach ($groups as $groupMember) { $collection->add($groupMember->group()->first()); } $users = UserMeta::where('user_id', '=', $this->id)->where('meta_key', '=', UserMeta::TYPE_INDEPENDENT_SPONSOR)->where('meta_value', '=', '1')->get(); foreach ($users as $userMeta) { $collection->add($userMeta->user()->first()); } return $collection; }
public static function getAllValidSponsors() { $userMeta = UserMeta::where('meta_key', '=', UserMeta::TYPE_INDEPENDENT_SPONSOR)->where('meta_value', '=', 1)->get(); $groups = Group::where('status', '=', Group::STATUS_ACTIVE)->get(); $results = new Collection(); $userIds = array(); foreach ($userMeta as $m) { $userIds[] = $m->user_id; } if (!empty($userIds)) { $users = User::whereIn('id', $userIds)->get(); foreach ($users as $user) { $row = array('display_name' => "{$user->fname} {$user->lname}", 'sponsor_type' => 'individual', 'id' => $user->id); $results->add($row); } } foreach ($groups as $group) { $row = array('display_name' => $group->display_name, 'sponsor_type' => 'group', 'id' => $group->id); $results->add($row); } return $results; }