/** * @param \AppBundle\Model\User $user * @param $skillId * @return mixed */ public function getSkillValues(\AppBundle\Model\User $user, $skillId) { $sql = sprintf("\n SELECT\n `uhs`.`user_id` AS `userId`,\n `uhs`.`value`,\n (`uhs`.`user_id` = %d) AS `isAttacker`\n FROM `combat` AS `c`\n JOIN `user_has_combat` AS `uhc` ON (`c`.`id` = `uhc`.`combat_id`)\n JOIN `user_has_skill` AS `uhs` ON (`uhc`.`user_id` = `uhs`.`user_id`)\n WHERE\n `c`.`id` = %d AND\n `uhs`.`skill_id` = %d;\n ", $user->getEntityHint()->getId(), $this->getEntityHint()->getId(), $skillId); /** @var Statement $stmt */ $stmt = $this->getDoctrineManager()->getConnection()->prepare($sql); $stmt->execute(); return $stmt->fetchAll(); }
public function loadUserByUsername($username) { $response = $this->client->get(sprintf('/user?access_token=%s', $username)); $userData = $response->json(); if (!$userData) { throw new \LogicException('Did not managed to get your user info from Github.'); } $user = new User(); $user->createFrom($userData); return $user; }
/** * @return int */ public function getOwnerId() { if (!$this->owner) { return null; } return $this->owner->getId(); }
/** * Set email * * @param string $email * * @return User */ public function setEmail($email) { if ($this->email && $this->email != $email) { $this->isEmailChanged = true; } return parent::setEmail($email); }
public function testRunningMigrations() { static::bootKernel(); // create user table Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email'); $table->string('password'); $table->timestamps(); }); User::create(['name' => 'John Doe', 'email' => '*****@*****.**', 'password' => 'pa$$word']); }
/** * @param User $user * * @return array */ public function normalizeUser(User $user) { $annotations = []; foreach ($user->getAnnotations() as $key => $annotation) { $annotations[] = ['key' => $key, 'value' => $annotation]; } return ['reference' => $user->getReference(), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'loginName' => $user->getLoginName(), 'annotations' => $annotations]; }
/** * User constructor. */ public function __construct() { parent::__construct(); }
/** * @inheritdoc * * @param User $other */ public function compareTo($other) { $ref1 = strtoupper($this->getReference()); $ref2 = strtoupper($other->getReference()); $c = new \Collator('en'); return $c->compare($ref1, $ref2); }