/** * Handle the "find by" when multiple are requested * * @param string $name Name of function called * @param array $args Arguments list * @param array $matches Matches from regex * @return \Modler\Collection collection */ public function handleFindByMultiple($name, $args, $matches) { $data = isset($args[0]) ? $args[0] : array(); $model = substr($name, 0, strlen($name) - 1); $collectionNs = '\\Psecio\\Gatekeeper\\' . $model . 'Collection'; if (!class_exists($collectionNs)) { throw new \Psecio\Gatekepper\Exception\ModelNotFoundException('Collection type ' . $model . ' could not be found'); } $model = g::modelFactory($model . 'Model'); $collection = new $collectionNs($this->getDb()); $collection = $this->getDb()->find($model, $data, true); return $collection; }
/** * Get the user throttle information * If not found, makes a new one * * @param integer $userId User ID * @return ThrottleModel instance */ public static function getUserThrottle($userId) { $throttle = Gatekeeper::findThrottleByUserId($userId); if ($throttle === false) { $data = array('user_id' => $userId, 'attempts' => 1, 'status' => ThrottleModel::STATUS_ALLOWED, 'last_attempt' => date('Y-m-d H:i:s'), 'status_change' => date('Y-m-d H:i:s')); $throttle = Gatekeeper::modelFactory('ThrottleModel', $data); } return $throttle; }
/** * Retrieve a user by the given credentials. * * @param array $credentials * @return \Illuminate\Auth\UserInterface */ public function retrieveByCredentials(array $credentials) { $user = Gatekeeper::modelFactory('UserModel'); $result = $user->findByUsername($credentials['username']); return $this->returnUser($user); }