protected function getGroup($id) { // Current authenticate user must be the owner // of the group $user = $this->getUser(); if (!is_null($user)) { return UserGroup::where('owner_id', $user->getKey())->where($user->getKeyName(), $id)->where('is_active', true)->first(); } }
/** * @return DMA\Friends\Models\UserGroup */ protected function getGroup() { $user = $this->getUser(); if (!is_null($user)) { if (!UserGroup::hasActiveMemberships($user)) { //1. If user don't have an active membership create a group for it $group = UserGroup::where('owner_id', $user->getKey())->where('is_active', true)->first(); $this->page['memberOfotherGroup'] = false; return $group; } else { $this->page['memberOfotherGroup'] = true; } } }
public function testResetGroups() { UserGroup::markInactiveGroups(); $this->assertEquals(0, count(UserGroup::where('is_active', '=', true)->get())); }