/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aUser) { $this->aUser->removeBet($this); } if (null !== $this->aParticipant) { $this->aParticipant->removeBet($this); } $this->user_id = null; $this->chosen_participant_id = null; $this->chosen_result = null; $this->medal = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Exclude object from result * * @param ChildUser $user Object to remove from the list of results * * @return $this|ChildUserQuery The current query, for fluid interface */ public function prune($user = null) { if ($user) { $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Filter the query by a related \ApostaAiApi\Models\User object * * @param \ApostaAiApi\Models\User|ObjectCollection $user The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildBetQuery The current query, for fluid interface */ public function filterByUser($user, $comparison = null) { if ($user instanceof \ApostaAiApi\Models\User) { return $this->addUsingAlias(BetTableMap::COL_USER_ID, $user->getId(), $comparison); } elseif ($user instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(BetTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByUser() only accepts arguments of type \\ApostaAiApi\\Models\\User or Collection'); } }
namespace ApostaAiApi\Routes; use ApostaAiApi\Middleware\NotLoggedInMiddleware; use ApostaAiApi\Middleware\LoggedInMiddleware; use ApostaAiApi\Models\User; use ApostaAiApi\Models\UserQuery; /** * Class UserRoute * * @package ApostaAiApi\Routes */ $this->group("/user", function () { $this->post("/register", function ($req, $res) { $postData = $req->getParsedBody(); $user = new User(); $user->setEmail($postData['email']); if ($user->emailExists()) { return $res->withJson(["Message" => "Email already exists"], 409); } $user->setBCryptPassword($postData['password']); $user->setName($postData['name']); $user->setScore(50); if ($user->save()) { return $res->withJson(["Message" => "Registered"], 200); } else { return $res->withJson(["Message" => "Error while registering"], 403); } })->add(new NotLoggedInMiddleware()); $this->post("/login", function ($req, $res) { $postData = $req->getParsedBody();