diff --git a/composer.lock b/composer.lock index 9620aa8..2c09718 100644 --- a/composer.lock +++ b/composer.lock @@ -153,16 +153,16 @@ }, { "name": "doctrine/cache", - "version": "1.12.1", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "4cf401d14df219fa6f38b671f5493449151c9ad8" + "reference": "331b4d5dbaeab3827976273e9356b3b453c300ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/4cf401d14df219fa6f38b671f5493449151c9ad8", - "reference": "4cf401d14df219fa6f38b671f5493449151c9ad8", + "url": "https://api.github.com/repos/doctrine/cache/zipball/331b4d5dbaeab3827976273e9356b3b453c300ce", + "reference": "331b4d5dbaeab3827976273e9356b3b453c300ce", "shasum": "" }, "require": { @@ -232,7 +232,7 @@ ], "support": { "issues": "https://github.com/doctrine/cache/issues", - "source": "https://github.com/doctrine/cache/tree/1.12.1" + "source": "https://github.com/doctrine/cache/tree/2.1.1" }, "funding": [ { @@ -248,7 +248,7 @@ "type": "tidelift" } ], - "time": "2021-07-17T14:39:21+00:00" + "time": "2021-07-17T14:49:29+00:00" }, { "name": "doctrine/collections", diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 030c4de..ecc817b 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,25 +1,42 @@ security: - # https://symfony.com/doc/current/security/experimental_authenticators.html - enable_authenticator_manager: true - # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers - providers: - users_in_memory: { memory: null } - firewalls: - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - main: - lazy: true - provider: users_in_memory + # https://symfony.com/doc/current/security/experimental_authenticators.html + enable_authenticator_manager: true + password_hashers: + App\Entity\User: + algorithm: auto - # activate different ways to authenticate - # https://symfony.com/doc/current/security.html#firewalls-authentication + # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers + providers: + # used to reload user from session & other features (e.g. switch_user) + app_user_provider: + entity: + class: App\Entity\User + property: email + firewalls: + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + main: + lazy: true + provider: app_user_provider + custom_authenticator: App\Security\AppUserAuthenticator + remember_me: + secret: "%kernel.secret%" + lifetime: 604800 # 1 week in seconds + path: / + logout: + path: app_logout + # where to redirect after logout + target: home - # https://symfony.com/doc/current/security/impersonating_user.html - # switch_user: true + # activate different ways to authenticate + # https://symfony.com/doc/current/security.html#firewalls-authentication - # Easy way to control access for large sections of your site - # Note: Only the *first* access control that matches will be used - access_control: - # - { path: ^/admin, roles: ROLE_ADMIN } - # - { path: ^/profile, roles: ROLE_USER } + # https://symfony.com/doc/current/security/impersonating_user.html + # switch_user: true + + # Easy way to control access for large sections of your site + # Note: Only the *first* access control that matches will be used + access_control: + # - { path: ^/admin, roles: ROLE_ADMIN } + # - { path: ^/profile, roles: ROLE_USER } diff --git a/migrations/Version20210816115519.php b/migrations/Version20210816115519.php new file mode 100644 index 0000000..a3cbe71 --- /dev/null +++ b/migrations/Version20210816115519.php @@ -0,0 +1,97 @@ +addSql('CREATE TABLE billing_address (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, civic VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, state VARCHAR(50) NOT NULL, country VARCHAR(50) NOT NULL, postal_code VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_6660E456A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, excerpt VARCHAR(255) NOT NULL, icon VARCHAR(100) NOT NULL, parent_id INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE discount (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, rate DOUBLE PRECISION NOT NULL, start DATETIME NOT NULL, end DATETIME NOT NULL, UNIQUE INDEX UNIQ_E1E0B40E4584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE fund (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, type VARCHAR(50) NOT NULL, account VARCHAR(50) NOT NULL, name VARCHAR(100) NOT NULL, expiration DATETIME NOT NULL, code VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_DC923E10A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE `order` (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, status VARCHAR(50) NOT NULL, edited_at DATETIME NOT NULL, INDEX IDX_F5299398A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE ordered_product (id INT AUTO_INCREMENT NOT NULL, order_id INT NOT NULL, product_id INT NOT NULL, quantity INT NOT NULL, INDEX IDX_E6F097B68D9F6D38 (order_id), INDEX IDX_E6F097B64584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE payment (id INT AUTO_INCREMENT NOT NULL, order_id INT NOT NULL, type VARCHAR(50) NOT NULL, amount DOUBLE PRECISION NOT NULL, status VARCHAR(50) NOT NULL, date DATETIME NOT NULL, UNIQUE INDEX UNIQ_6D28840D8D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE photo (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, title VARCHAR(50) NOT NULL, caption VARCHAR(50) NOT NULL, url VARCHAR(255) NOT NULL, INDEX IDX_14B784184584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, category_id INT NOT NULL, user_id INT NOT NULL, name VARCHAR(50) NOT NULL, excerpt LONGTEXT NOT NULL, description LONGTEXT NOT NULL, quantity INT NOT NULL, price DOUBLE PRECISION NOT NULL, edited_at DATETIME NOT NULL, INDEX IDX_D34A04AD12469DE2 (category_id), INDEX IDX_D34A04ADA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE profile (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, photo VARCHAR(255) NOT NULL, first_name VARCHAR(255) NOT NULL, last_nane VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone_number VARCHAR(45) NOT NULL, UNIQUE INDEX UNIQ_8157AA0FA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE role (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE shipment (id INT AUTO_INCREMENT NOT NULL, order_id INT NOT NULL, service VARCHAR(50) NOT NULL, recipient VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, status VARCHAR(50) NOT NULL, delivery_time DATETIME NOT NULL, UNIQUE INDEX UNIQ_2CB20DC8D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE shipping (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, service VARCHAR(50) NOT NULL, region VARCHAR(50) NOT NULL, cost DOUBLE PRECISION NOT NULL, delivery_date DATETIME NOT NULL, INDEX IDX_2D1C17244584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE specification (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, name VARCHAR(50) NOT NULL, value VARCHAR(50) NOT NULL, INDEX IDX_E3F1A9A4584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE tax (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, name VARCHAR(50) NOT NULL, rate DOUBLE PRECISION NOT NULL, INDEX IDX_8E81BA764584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE user_role (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, role_id INT NOT NULL, INDEX IDX_2DE8C6A3A76ED395 (user_id), INDEX IDX_2DE8C6A3D60322AC (role_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE billing_address ADD CONSTRAINT FK_6660E456A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE discount ADD CONSTRAINT FK_E1E0B40E4584665A FOREIGN KEY (product_id) REFERENCES product (id)'); + $this->addSql('ALTER TABLE fund ADD CONSTRAINT FK_DC923E10A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F5299398A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE ordered_product ADD CONSTRAINT FK_E6F097B68D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)'); + $this->addSql('ALTER TABLE ordered_product ADD CONSTRAINT FK_E6F097B64584665A FOREIGN KEY (product_id) REFERENCES product (id)'); + $this->addSql('ALTER TABLE payment ADD CONSTRAINT FK_6D28840D8D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)'); + $this->addSql('ALTER TABLE photo ADD CONSTRAINT FK_14B784184584665A FOREIGN KEY (product_id) REFERENCES product (id)'); + $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD12469DE2 FOREIGN KEY (category_id) REFERENCES category (id)'); + $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04ADA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE profile ADD CONSTRAINT FK_8157AA0FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC8D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)'); + $this->addSql('ALTER TABLE shipping ADD CONSTRAINT FK_2D1C17244584665A FOREIGN KEY (product_id) REFERENCES product (id)'); + $this->addSql('ALTER TABLE specification ADD CONSTRAINT FK_E3F1A9A4584665A FOREIGN KEY (product_id) REFERENCES product (id)'); + $this->addSql('ALTER TABLE tax ADD CONSTRAINT FK_8E81BA764584665A FOREIGN KEY (product_id) REFERENCES product (id)'); + $this->addSql('ALTER TABLE user_role ADD CONSTRAINT FK_2DE8C6A3A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); + $this->addSql('ALTER TABLE user_role ADD CONSTRAINT FK_2DE8C6A3D60322AC FOREIGN KEY (role_id) REFERENCES role (id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD12469DE2'); + $this->addSql('ALTER TABLE ordered_product DROP FOREIGN KEY FK_E6F097B68D9F6D38'); + $this->addSql('ALTER TABLE payment DROP FOREIGN KEY FK_6D28840D8D9F6D38'); + $this->addSql('ALTER TABLE shipment DROP FOREIGN KEY FK_2CB20DC8D9F6D38'); + $this->addSql('ALTER TABLE discount DROP FOREIGN KEY FK_E1E0B40E4584665A'); + $this->addSql('ALTER TABLE ordered_product DROP FOREIGN KEY FK_E6F097B64584665A'); + $this->addSql('ALTER TABLE photo DROP FOREIGN KEY FK_14B784184584665A'); + $this->addSql('ALTER TABLE shipping DROP FOREIGN KEY FK_2D1C17244584665A'); + $this->addSql('ALTER TABLE specification DROP FOREIGN KEY FK_E3F1A9A4584665A'); + $this->addSql('ALTER TABLE tax DROP FOREIGN KEY FK_8E81BA764584665A'); + $this->addSql('ALTER TABLE user_role DROP FOREIGN KEY FK_2DE8C6A3D60322AC'); + $this->addSql('ALTER TABLE billing_address DROP FOREIGN KEY FK_6660E456A76ED395'); + $this->addSql('ALTER TABLE fund DROP FOREIGN KEY FK_DC923E10A76ED395'); + $this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F5299398A76ED395'); + $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04ADA76ED395'); + $this->addSql('ALTER TABLE profile DROP FOREIGN KEY FK_8157AA0FA76ED395'); + $this->addSql('ALTER TABLE user_role DROP FOREIGN KEY FK_2DE8C6A3A76ED395'); + $this->addSql('DROP TABLE billing_address'); + $this->addSql('DROP TABLE category'); + $this->addSql('DROP TABLE discount'); + $this->addSql('DROP TABLE fund'); + $this->addSql('DROP TABLE `order`'); + $this->addSql('DROP TABLE ordered_product'); + $this->addSql('DROP TABLE payment'); + $this->addSql('DROP TABLE photo'); + $this->addSql('DROP TABLE product'); + $this->addSql('DROP TABLE profile'); + $this->addSql('DROP TABLE role'); + $this->addSql('DROP TABLE shipment'); + $this->addSql('DROP TABLE shipping'); + $this->addSql('DROP TABLE specification'); + $this->addSql('DROP TABLE tax'); + $this->addSql('DROP TABLE user'); + $this->addSql('DROP TABLE user_role'); + } +} diff --git a/src/Controller/AccountController.php b/src/Controller/AccountController.php new file mode 100644 index 0000000..f8be7e5 --- /dev/null +++ b/src/Controller/AccountController.php @@ -0,0 +1,75 @@ +getUser()) { + return $this->redirectToRoute('home'); + } + + return $this->render('account/index.html.twig'); + } + /** + * @Route("/login", name="user_login") + */ + + public function login(AuthenticationUtils $authenticationUtils): Response + { + if ($this->getUser()) { + return $this->redirectToRoute('home'); + } + + // get the login error if there is one + $error = $authenticationUtils->getLastAuthenticationError(); + // last username entered by the user + $lastUsername = $authenticationUtils->getLastUsername(); + + return $this->render('account/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); + } + /** + * @Route("/register", name="user_register") + */ + public function register(Request $request, UserPasswordHasherInterface $hasher): Response + { + if ($request->request->get('password') !== $request->request->get('confirm')) { + echo ('Confirmation Password does not match with Password...'); + } else { + if ($request->request->get('email') != null && $request->request->get('password') != null) { + $em = $this->getDoctrine()->getManager(); + $user = new User(); + // $user->firstname = $request->request->get('first_name'); + // $user->lastname = $request->request->get('last_name'); + $user->setEmail($request->request->get('email')); + $user->setPassword($hasher->hashPassword($user, $request->request->get('password'))); + $em->persist($user); + $em->flush(); + return $this->redirect("/"); + } + } + return $this->render('account/register.html.twig'); + } + /** + * @Route("/logout", name="app_logout") + */ + public function logout() + { + throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); + } +} diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index a29686b..f002189 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -54,13 +54,4 @@ public function cart(): Response // 'controller_name' => 'HomeController', // ]); } - /** - * @Route("/account", name="account") - */ - public function account(): Response - { - return $this->render('account/login-register.html.twig', [ - 'controller_name' => 'HomeController', - ]); - } } diff --git a/src/Entity/BillingAddress.php b/src/Entity/BillingAddress.php new file mode 100644 index 0000000..9b7df2e --- /dev/null +++ b/src/Entity/BillingAddress.php @@ -0,0 +1,127 @@ +id; + } + + public function getUser(): ?User + { + return $this->User; + } + + public function setUser(User $User): self + { + $this->User = $User; + + return $this; + } + + public function getCivic(): ?string + { + return $this->Civic; + } + + public function setCivic(string $Civic): self + { + $this->Civic = $Civic; + + return $this; + } + + public function getCity(): ?string + { + return $this->City; + } + + public function setCity(string $City): self + { + $this->City = $City; + + return $this; + } + + public function getState(): ?string + { + return $this->State; + } + + public function setState(string $State): self + { + $this->State = $State; + + return $this; + } + + public function getCountry(): ?string + { + return $this->Country; + } + + public function setCountry(string $Country): self + { + $this->Country = $Country; + + return $this; + } + + public function getPostalCode(): ?string + { + return $this->PostalCode; + } + + public function setPostalCode(string $PostalCode): self + { + $this->PostalCode = $PostalCode; + + return $this; + } +} diff --git a/src/Entity/Category.php b/src/Entity/Category.php new file mode 100644 index 0000000..3e9d5ed --- /dev/null +++ b/src/Entity/Category.php @@ -0,0 +1,92 @@ +id; + } + + public function getName(): ?string + { + return $this->Name; + } + + public function setName(string $Name): self + { + $this->Name = $Name; + + return $this; + } + + public function getExcerpt(): ?string + { + return $this->Excerpt; + } + + public function setExcerpt(string $Excerpt): self + { + $this->Excerpt = $Excerpt; + + return $this; + } + + public function getIcon(): ?string + { + return $this->Icon; + } + + public function setIcon(string $Icon): self + { + $this->Icon = $Icon; + + return $this; + } + + public function getParentId(): ?int + { + return $this->ParentId; + } + + public function setParentId(int $ParentId): self + { + $this->ParentId = $ParentId; + + return $this; + } +} diff --git a/src/Entity/Discount.php b/src/Entity/Discount.php new file mode 100644 index 0000000..84870a3 --- /dev/null +++ b/src/Entity/Discount.php @@ -0,0 +1,93 @@ +id; + } + + public function getProduct(): ?Product + { + return $this->Product; + } + + public function setProduct(Product $Product): self + { + $this->Product = $Product; + + return $this; + } + + public function getRate(): ?float + { + return $this->Rate; + } + + public function setRate(float $Rate): self + { + $this->Rate = $Rate; + + return $this; + } + + public function getStart(): ?\DateTimeInterface + { + return $this->Start; + } + + public function setStart(\DateTimeInterface $Start): self + { + $this->Start = $Start; + + return $this; + } + + public function getEnd(): ?\DateTimeInterface + { + return $this->End; + } + + public function setEnd(\DateTimeInterface $End): self + { + $this->End = $End; + + return $this; + } +} diff --git a/src/Entity/Fund.php b/src/Entity/Fund.php new file mode 100644 index 0000000..803c457 --- /dev/null +++ b/src/Entity/Fund.php @@ -0,0 +1,127 @@ +id; + } + + public function getUser(): ?User + { + return $this->User; + } + + public function setUser(User $User): self + { + $this->User = $User; + + return $this; + } + + public function getType(): ?string + { + return $this->Type; + } + + public function setType(string $Type): self + { + $this->Type = $Type; + + return $this; + } + + public function getAccount(): ?string + { + return $this->Account; + } + + public function setAccount(string $Account): self + { + $this->Account = $Account; + + return $this; + } + + public function getName(): ?string + { + return $this->Name; + } + + public function setName(string $Name): self + { + $this->Name = $Name; + + return $this; + } + + public function getExpiration(): ?\DateTimeInterface + { + return $this->Expiration; + } + + public function setExpiration(\DateTimeInterface $Expiration): self + { + $this->Expiration = $Expiration; + + return $this; + } + + public function getCode(): ?string + { + return $this->Code; + } + + public function setCode(string $Code): self + { + $this->Code = $Code; + + return $this; + } +} diff --git a/src/Entity/Order.php b/src/Entity/Order.php new file mode 100644 index 0000000..64460c7 --- /dev/null +++ b/src/Entity/Order.php @@ -0,0 +1,119 @@ +orderedProducts = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getUser(): ?User + { + return $this->User; + } + + public function setUser(?User $User): self + { + $this->User = $User; + + return $this; + } + + public function getStatus(): ?string + { + return $this->Status; + } + + public function setStatus(string $Status): self + { + $this->Status = $Status; + + return $this; + } + + public function getEditedAt(): ?\DateTimeInterface + { + return $this->EditedAt; + } + + public function setEditedAt(\DateTimeInterface $EditedAt): self + { + $this->EditedAt = $EditedAt; + + return $this; + } + + /** + * @return Collection|OrderedProduct[] + */ + public function getOrderedProducts(): Collection + { + return $this->orderedProducts; + } + + public function addOrderedProduct(OrderedProduct $orderedProduct): self + { + if (!$this->orderedProducts->contains($orderedProduct)) { + $this->orderedProducts[] = $orderedProduct; + $orderedProduct->setOrder($this); + } + + return $this; + } + + public function removeOrderedProduct(OrderedProduct $orderedProduct): self + { + if ($this->orderedProducts->removeElement($orderedProduct)) { + // set the owning side to null (unless already changed) + if ($orderedProduct->getOrder() === $this) { + $orderedProduct->setOrder(null); + } + } + + return $this; + } +} diff --git a/src/Entity/OrderedProduct.php b/src/Entity/OrderedProduct.php new file mode 100644 index 0000000..f247f63 --- /dev/null +++ b/src/Entity/OrderedProduct.php @@ -0,0 +1,77 @@ +id; + } + + public function getOrder(): ?Order + { + return $this->Order; + } + + public function setOrder(?Order $Order): self + { + $this->Order = $Order; + + return $this; + } + + public function getProduct(): ?Product + { + return $this->Product; + } + + public function setProduct(?Product $Product): self + { + $this->Product = $Product; + + return $this; + } + + public function getQuantity(): ?int + { + return $this->Quantity; + } + + public function setQuantity(int $Quantity): self + { + $this->Quantity = $Quantity; + + return $this; + } +} diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php new file mode 100644 index 0000000..ea52887 --- /dev/null +++ b/src/Entity/Payment.php @@ -0,0 +1,110 @@ +id; + } + + public function getOrder(): ?Order + { + return $this->Order; + } + + public function setOrder(Order $Order): self + { + $this->Order = $Order; + + return $this; + } + + public function getType(): ?string + { + return $this->Type; + } + + public function setType(string $Type): self + { + $this->Type = $Type; + + return $this; + } + + public function getAmount(): ?float + { + return $this->Amount; + } + + public function setAmount(float $Amount): self + { + $this->Amount = $Amount; + + return $this; + } + + public function getStatus(): ?string + { + return $this->Status; + } + + public function setStatus(string $Status): self + { + $this->Status = $Status; + + return $this; + } + + public function getDate(): ?\DateTimeInterface + { + return $this->Date; + } + + public function setDate(\DateTimeInterface $Date): self + { + $this->Date = $Date; + + return $this; + } +} diff --git a/src/Entity/Photo.php b/src/Entity/Photo.php new file mode 100644 index 0000000..bdf3f7c --- /dev/null +++ b/src/Entity/Photo.php @@ -0,0 +1,93 @@ +id; + } + + public function getProduct(): ?Product + { + return $this->Product; + } + + public function setProduct(?Product $Product): self + { + $this->Product = $Product; + + return $this; + } + + public function getTitle(): ?string + { + return $this->Title; + } + + public function setTitle(string $Title): self + { + $this->Title = $Title; + + return $this; + } + + public function getCaption(): ?string + { + return $this->Caption; + } + + public function setCaption(string $Caption): self + { + $this->Caption = $Caption; + + return $this; + } + + public function getUrl(): ?string + { + return $this->Url; + } + + public function setUrl(string $Url): self + { + $this->Url = $Url; + + return $this; + } +} diff --git a/src/Entity/Product.php b/src/Entity/Product.php new file mode 100644 index 0000000..1db98fc --- /dev/null +++ b/src/Entity/Product.php @@ -0,0 +1,312 @@ +photos = new ArrayCollection(); + $this->specifications = new ArrayCollection(); + $this->taxes = new ArrayCollection(); + $this->shippings = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getCategory(): ?Category + { + return $this->Category; + } + + public function setCategory(?Category $Category): self + { + $this->Category = $Category; + + return $this; + } + + public function getUser(): ?User + { + return $this->User; + } + + public function setUser(?User $User): self + { + $this->User = $User; + + return $this; + } + + public function getName(): ?string + { + return $this->Name; + } + + public function setName(string $Name): self + { + $this->Name = $Name; + + return $this; + } + + public function getExcerpt(): ?string + { + return $this->Excerpt; + } + + public function setExcerpt(string $Excerpt): self + { + $this->Excerpt = $Excerpt; + + return $this; + } + + public function getDescription(): ?string + { + return $this->Description; + } + + public function setDescription(string $Description): self + { + $this->Description = $Description; + + return $this; + } + + public function getQuantity(): ?int + { + return $this->Quantity; + } + + public function setQuantity(int $Quantity): self + { + $this->Quantity = $Quantity; + + return $this; + } + + public function getPrice(): ?float + { + return $this->Price; + } + + public function setPrice(float $Price): self + { + $this->Price = $Price; + + return $this; + } + + public function getEditedAt(): ?\DateTimeInterface + { + return $this->EditedAt; + } + + public function setEditedAt(\DateTimeInterface $EditedAt): self + { + $this->EditedAt = $EditedAt; + + return $this; + } + + /** + * @return Collection|Photo[] + */ + public function getPhotos(): Collection + { + return $this->photos; + } + + public function addPhoto(Photo $photo): self + { + if (!$this->photos->contains($photo)) { + $this->photos[] = $photo; + $photo->setProduct($this); + } + + return $this; + } + + public function removePhoto(Photo $photo): self + { + if ($this->photos->removeElement($photo)) { + // set the owning side to null (unless already changed) + if ($photo->getProduct() === $this) { + $photo->setProduct(null); + } + } + + return $this; + } + + /** + * @return Collection|Specification[] + */ + public function getSpecifications(): Collection + { + return $this->specifications; + } + + public function addSpecification(Specification $specification): self + { + if (!$this->specifications->contains($specification)) { + $this->specifications[] = $specification; + $specification->setProduct($this); + } + + return $this; + } + + public function removeSpecification(Specification $specification): self + { + if ($this->specifications->removeElement($specification)) { + // set the owning side to null (unless already changed) + if ($specification->getProduct() === $this) { + $specification->setProduct(null); + } + } + + return $this; + } + + /** + * @return Collection|Tax[] + */ + public function getTaxes(): Collection + { + return $this->taxes; + } + + public function addTax(Tax $tax): self + { + if (!$this->taxes->contains($tax)) { + $this->taxes[] = $tax; + $tax->setProduct($this); + } + + return $this; + } + + public function removeTax(Tax $tax): self + { + if ($this->taxes->removeElement($tax)) { + // set the owning side to null (unless already changed) + if ($tax->getProduct() === $this) { + $tax->setProduct(null); + } + } + + return $this; + } + + /** + * @return Collection|Shipping[] + */ + public function getShippings(): Collection + { + return $this->shippings; + } + + public function addShipping(Shipping $shipping): self + { + if (!$this->shippings->contains($shipping)) { + $this->shippings[] = $shipping; + $shipping->setProduct($this); + } + + return $this; + } + + public function removeShipping(Shipping $shipping): self + { + if ($this->shippings->removeElement($shipping)) { + // set the owning side to null (unless already changed) + if ($shipping->getProduct() === $this) { + $shipping->setProduct(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Profile.php b/src/Entity/Profile.php new file mode 100644 index 0000000..1227c94 --- /dev/null +++ b/src/Entity/Profile.php @@ -0,0 +1,127 @@ +id; + } + + public function getUser(): ?User + { + return $this->User; + } + + public function setUser(User $User): self + { + $this->User = $User; + + return $this; + } + + public function getPhoto(): ?string + { + return $this->Photo; + } + + public function setPhoto(string $Photo): self + { + $this->Photo = $Photo; + + return $this; + } + + public function getFirstName(): ?string + { + return $this->FirstName; + } + + public function setFirstName(string $FirstName): self + { + $this->FirstName = $FirstName; + + return $this; + } + + public function getLastNane(): ?string + { + return $this->LastNane; + } + + public function setLastNane(string $LastNane): self + { + $this->LastNane = $LastNane; + + return $this; + } + + public function getEmail(): ?string + { + return $this->Email; + } + + public function setEmail(string $Email): self + { + $this->Email = $Email; + + return $this; + } + + public function getPhoneNumber(): ?string + { + return $this->PhoneNumber; + } + + public function setPhoneNumber(string $PhoneNumber): self + { + $this->PhoneNumber = $PhoneNumber; + + return $this; + } +} diff --git a/src/Entity/Role.php b/src/Entity/Role.php new file mode 100644 index 0000000..67a58e6 --- /dev/null +++ b/src/Entity/Role.php @@ -0,0 +1,55 @@ +userRoles = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function setId(int $Id): self + { + $this->Id = $Id; + + return $this; + } + + public function getName(): ?string + { + return $this->Name; + } + + public function setName(string $Name): self + { + $this->Name = $Name; + + return $this; + } +} diff --git a/src/Entity/Shipment.php b/src/Entity/Shipment.php new file mode 100644 index 0000000..2ccf1fe --- /dev/null +++ b/src/Entity/Shipment.php @@ -0,0 +1,127 @@ +id; + } + + public function getOrder(): ?Order + { + return $this->Order; + } + + public function setOrder(Order $Order): self + { + $this->Order = $Order; + + return $this; + } + + public function getService(): ?string + { + return $this->Service; + } + + public function setService(string $Service): self + { + $this->Service = $Service; + + return $this; + } + + public function getRecipient(): ?string + { + return $this->Recipient; + } + + public function setRecipient(string $Recipient): self + { + $this->Recipient = $Recipient; + + return $this; + } + + public function getAddress(): ?string + { + return $this->Address; + } + + public function setAddress(string $Address): self + { + $this->Address = $Address; + + return $this; + } + + public function getStatus(): ?string + { + return $this->Status; + } + + public function setStatus(string $Status): self + { + $this->Status = $Status; + + return $this; + } + + public function getDeliveryTime(): ?\DateTimeInterface + { + return $this->DeliveryTime; + } + + public function setDeliveryTime(\DateTimeInterface $DeliveryTime): self + { + $this->DeliveryTime = $DeliveryTime; + + return $this; + } +} diff --git a/src/Entity/Shipping.php b/src/Entity/Shipping.php new file mode 100644 index 0000000..bb0edbb --- /dev/null +++ b/src/Entity/Shipping.php @@ -0,0 +1,110 @@ +id; + } + + public function getProduct(): ?Product + { + return $this->Product; + } + + public function setProduct(?Product $Product): self + { + $this->Product = $Product; + + return $this; + } + + public function getService(): ?string + { + return $this->Service; + } + + public function setService(string $Service): self + { + $this->Service = $Service; + + return $this; + } + + public function getRegion(): ?string + { + return $this->Region; + } + + public function setRegion(string $Region): self + { + $this->Region = $Region; + + return $this; + } + + public function getCost(): ?float + { + return $this->Cost; + } + + public function setCost(float $Cost): self + { + $this->Cost = $Cost; + + return $this; + } + + public function getDeliveryDate(): ?\DateTimeInterface + { + return $this->DeliveryDate; + } + + public function setDeliveryDate(\DateTimeInterface $DeliveryDate): self + { + $this->DeliveryDate = $DeliveryDate; + + return $this; + } +} diff --git a/src/Entity/Specification.php b/src/Entity/Specification.php new file mode 100644 index 0000000..4b81a2e --- /dev/null +++ b/src/Entity/Specification.php @@ -0,0 +1,76 @@ +id; + } + + public function getProduct(): ?Product + { + return $this->Product; + } + + public function setProduct(?Product $Product): self + { + $this->Product = $Product; + + return $this; + } + + public function getName(): ?string + { + return $this->Name; + } + + public function setName(string $Name): self + { + $this->Name = $Name; + + return $this; + } + + public function getValue(): ?string + { + return $this->Value; + } + + public function setValue(string $Value): self + { + $this->Value = $Value; + + return $this; + } +} diff --git a/src/Entity/Tax.php b/src/Entity/Tax.php new file mode 100644 index 0000000..5695cc7 --- /dev/null +++ b/src/Entity/Tax.php @@ -0,0 +1,76 @@ +id; + } + + public function getProduct(): ?Product + { + return $this->Product; + } + + public function setProduct(?Product $Product): self + { + $this->Product = $Product; + + return $this; + } + + public function getName(): ?string + { + return $this->Name; + } + + public function setName(string $Name): self + { + $this->Name = $Name; + + return $this; + } + + public function getRate(): ?float + { + return $this->Rate; + } + + public function setRate(float $Rate): self + { + $this->Rate = $Rate; + + return $this; + } +} diff --git a/src/Entity/User.php b/src/Entity/User.php new file mode 100644 index 0000000..a82a61f --- /dev/null +++ b/src/Entity/User.php @@ -0,0 +1,204 @@ +userRoles = new ArrayCollection(); + $this->products = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(string $email) + { + $this->email = $email; + + return $this; + } + + /** + * A visual identifier that represents this user. + * + * @see UserInterface + */ + public function getUserIdentifier(): string + { + return (string) $this->email; + } + + /** + * @deprecated since Symfony 5.3, use getUserIdentifier instead + */ + public function getUsername(): string + { + return (string) $this->email; + } + + /** + * @see UserInterface + */ + public function getRoles(): array + { + $roles = $this->roles; + // guarantee every user at least has ROLE_USER + $roles[] = 'ROLE_USER'; + + return array_unique($roles); + } + + public function setRoles(array $roles): self + { + $this->roles = $roles; + + return $this; + } + + /** + * @see PasswordAuthenticatedUserInterface + */ + public function getPassword(): string + { + return $this->password; + } + + public function setPassword(string $password): self + { + $this->password = $password; + + return $this; + } + + /** + * Returning a salt is only needed, if you are not using a modern + * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml. + * + * @see UserInterface + */ + public function getSalt(): ?string + { + return null; + } + + /** + * @see UserInterface + */ + public function eraseCredentials() + { + // If you store any temporary, sensitive data on the user, clear it here + // $this->plainPassword = null; + } + + /** + * @return Collection|UserRole[] + */ + public function getUserRoles(): Collection + { + return $this->userRoles; + } + + public function addUserRole(UserRole $userRole): self + { + if (!$this->userRoles->contains($userRole)) { + $this->userRoles[] = $userRole; + $userRole->setUser($this); + } + + return $this; + } + + public function removeUserRole(UserRole $userRole): self + { + if ($this->userRoles->removeElement($userRole)) { + // set the owning side to null (unless already changed) + if ($userRole->getUser() === $this) { + $userRole->setUser(null); + } + } + + return $this; + } + + /** + * @return Collection|Product[] + */ + public function getProducts(): Collection + { + return $this->products; + } + + public function addProduct(Product $product): self + { + if (!$this->products->contains($product)) { + $this->products[] = $product; + $product->setUser($this); + } + + return $this; + } + + public function removeProduct(Product $product): self + { + if ($this->products->removeElement($product)) { + // set the owning side to null (unless already changed) + if ($product->getUser() === $this) { + $product->setUser(null); + } + } + + return $this; + } +} diff --git a/src/Entity/UserRole.php b/src/Entity/UserRole.php new file mode 100644 index 0000000..ef256b8 --- /dev/null +++ b/src/Entity/UserRole.php @@ -0,0 +1,60 @@ +id; + } + + public function getUser(): ?User + { + return $this->User; + } + + public function setUser(?User $User): self + { + $this->User = $User; + + return $this; + } + + public function getRole(): ?Role + { + return $this->RoleId; + } + + public function setRole(?Role $Role): self + { + $this->Role = $Role; + + return $this; + } +} diff --git a/src/Repository/BillingAddressRepository.php b/src/Repository/BillingAddressRepository.php new file mode 100644 index 0000000..fa7e569 --- /dev/null +++ b/src/Repository/BillingAddressRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('b') + ->andWhere('b.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('b.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?BillingAddress + { + return $this->createQueryBuilder('b') + ->andWhere('b.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php new file mode 100644 index 0000000..a12b228 --- /dev/null +++ b/src/Repository/CategoryRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('c') + ->andWhere('c.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('c.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Category + { + return $this->createQueryBuilder('c') + ->andWhere('c.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/DiscountRepository.php b/src/Repository/DiscountRepository.php new file mode 100644 index 0000000..69a85cb --- /dev/null +++ b/src/Repository/DiscountRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('d') + ->andWhere('d.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('d.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Discount + { + return $this->createQueryBuilder('d') + ->andWhere('d.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/FundRepository.php b/src/Repository/FundRepository.php new file mode 100644 index 0000000..8e4be32 --- /dev/null +++ b/src/Repository/FundRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('f') + ->andWhere('f.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('f.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Fund + { + return $this->createQueryBuilder('f') + ->andWhere('f.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php new file mode 100644 index 0000000..beb69bf --- /dev/null +++ b/src/Repository/OrderRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('o.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Order + { + return $this->createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/OrderedProductRepository.php b/src/Repository/OrderedProductRepository.php new file mode 100644 index 0000000..b0c0912 --- /dev/null +++ b/src/Repository/OrderedProductRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('o.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?OrderedProduct + { + return $this->createQueryBuilder('o') + ->andWhere('o.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/PaymentRepository.php b/src/Repository/PaymentRepository.php new file mode 100644 index 0000000..6876a81 --- /dev/null +++ b/src/Repository/PaymentRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('p.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Payment + { + return $this->createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/PhotoRepository.php b/src/Repository/PhotoRepository.php new file mode 100644 index 0000000..14c66a5 --- /dev/null +++ b/src/Repository/PhotoRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('p.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Photo + { + return $this->createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php new file mode 100644 index 0000000..c34bb70 --- /dev/null +++ b/src/Repository/ProductRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('p.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Product + { + return $this->createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/ProfileRepository.php b/src/Repository/ProfileRepository.php new file mode 100644 index 0000000..098b0af --- /dev/null +++ b/src/Repository/ProfileRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('p.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Profile + { + return $this->createQueryBuilder('p') + ->andWhere('p.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/RoleRepository.php b/src/Repository/RoleRepository.php new file mode 100644 index 0000000..ab32e60 --- /dev/null +++ b/src/Repository/RoleRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('r') + ->andWhere('r.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('r.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Role + { + return $this->createQueryBuilder('r') + ->andWhere('r.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/ShipmentRepository.php b/src/Repository/ShipmentRepository.php new file mode 100644 index 0000000..ccf29de --- /dev/null +++ b/src/Repository/ShipmentRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('s.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Shipment + { + return $this->createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/ShippingRepository.php b/src/Repository/ShippingRepository.php new file mode 100644 index 0000000..cc480a2 --- /dev/null +++ b/src/Repository/ShippingRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('s.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Shipping + { + return $this->createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/SpecificationRepository.php b/src/Repository/SpecificationRepository.php new file mode 100644 index 0000000..7dd65ff --- /dev/null +++ b/src/Repository/SpecificationRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('s.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Specification + { + return $this->createQueryBuilder('s') + ->andWhere('s.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/TaxRepository.php b/src/Repository/TaxRepository.php new file mode 100644 index 0000000..af08836 --- /dev/null +++ b/src/Repository/TaxRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('t') + ->andWhere('t.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('t.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Tax + { + return $this->createQueryBuilder('t') + ->andWhere('t.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php new file mode 100644 index 0000000..5eaa8c5 --- /dev/null +++ b/src/Repository/UserRepository.php @@ -0,0 +1,67 @@ +setPassword($newHashedPassword); + $this->_em->persist($user); + $this->_em->flush(); + } + + // /** + // * @return User[] Returns an array of User objects + // */ + /* + public function findByExampleField($value) + { + return $this->createQueryBuilder('u') + ->andWhere('u.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('u.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?User + { + return $this->createQueryBuilder('u') + ->andWhere('u.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/UserRoleRepository.php b/src/Repository/UserRoleRepository.php new file mode 100644 index 0000000..3ade481 --- /dev/null +++ b/src/Repository/UserRoleRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('u') + ->andWhere('u.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('u.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?UserRole + { + return $this->createQueryBuilder('u') + ->andWhere('u.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Security/AppUserAuthenticator.php b/src/Security/AppUserAuthenticator.php new file mode 100644 index 0000000..d03f4af --- /dev/null +++ b/src/Security/AppUserAuthenticator.php @@ -0,0 +1,62 @@ +urlGenerator = $urlGenerator; + } + + public function authenticate(Request $request): PassportInterface + { + $email = $request->request->get('email', ''); + + $request->getSession()->set(Security::LAST_USERNAME, $email); + + return new Passport( + new UserBadge($email), + new PasswordCredentials($request->request->get('password', '')), + [ + new CsrfTokenBadge('authenticate', $request->get('_csrf_token')), + ] + ); + } + + public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response + { + if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) { + return new RedirectResponse('home'); + } + + // Redirect To home page + return new RedirectResponse($this->urlGenerator->generate('home')); + //throw new \Exception('TODO: provide a valid redirect inside '.__FILE__); + } + + protected function getLoginUrl(Request $request): string + { + return $this->urlGenerator->generate(self::LOGIN_ROUTE); + } +} diff --git a/templates/account/index.html.twig b/templates/account/index.html.twig index dd3f86a..61d9c5f 100644 --- a/templates/account/index.html.twig +++ b/templates/account/index.html.twig @@ -1,6 +1,6 @@ {% extends './base.html.twig' %} {% block main %} -

Contact

+

Account


{% endblock %} diff --git a/templates/account/login-register.html.twig b/templates/account/login-register.html.twig deleted file mode 100644 index 5f0b021..0000000 --- a/templates/account/login-register.html.twig +++ /dev/null @@ -1,76 +0,0 @@ -{% extends './base.html.twig' %} - -{% block main %} - -
-
-
-
- -
- -
-
-
-
- -
-
-
-
-
- -{% endblock %} diff --git a/templates/account/login.html.twig b/templates/account/login.html.twig new file mode 100644 index 0000000..119634d --- /dev/null +++ b/templates/account/login.html.twig @@ -0,0 +1,57 @@ +{% extends './base.html.twig' %} + +{% block main %} + +
+
+
+
+ +
+ {% if app.user %} +
+ You are logged in as + {{ app.user.email }}, + Logout +
+ {% endif %} + {% if error %} +
{{ error.messageKey|trans(error.messageData, 'security') }}
+ {% endif %} + +
+
+
+
+
+ +{% endblock %} diff --git a/templates/account/register.html.twig b/templates/account/register.html.twig new file mode 100644 index 0000000..2659d4d --- /dev/null +++ b/templates/account/register.html.twig @@ -0,0 +1,45 @@ +{% extends './base.html.twig' %} + +{% block main %} + +
+
+
+ +
+
+ +
+
+
+
+
+ +{% endblock %} diff --git a/templates/base.html.twig b/templates/base.html.twig index 3756a9f..4c2155d 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -332,13 +332,13 @@ @@ -407,448 +421,370 @@ + + + +
+
+
+
{% endblock %}{% block main %}{% endblock %}{% block footer %}