From 853b570f0f7702e3825ef747d4ebfbe27123527a Mon Sep 17 00:00:00 2001 From: thisfro Date: Mon, 14 Jun 2021 14:09:44 +0200 Subject: [PATCH] Setup PLZ field for user --- migrations/Version20210614104026.php | 34 +++++++++++++++++++++++ src/Entity/User.php | 17 ++++++++++++ src/Form/RegistrationFormType.php | 1 + templates/registration/register.html.twig | 3 ++ templates/user/index.html.twig | 7 ++++- 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 migrations/Version20210614104026.php diff --git a/migrations/Version20210614104026.php b/migrations/Version20210614104026.php new file mode 100644 index 0000000..8735f19 --- /dev/null +++ b/migrations/Version20210614104026.php @@ -0,0 +1,34 @@ +addSql('ALTER TABLE offering ALTER description SET NOT NULL'); + $this->addSql('ALTER TABLE "user" ADD zip_code INT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE "user" DROP zip_code'); + $this->addSql('ALTER TABLE offering ALTER description DROP NOT NULL'); + } +} diff --git a/src/Entity/User.php b/src/Entity/User.php index 9a661e3..7207c3e 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -59,6 +59,11 @@ class User implements UserInterface */ private $wishes; + /** + * @ORM\Column(type="integer", nullable=true) + */ + private $zipCode; + public function __construct() { $this->offerings = new ArrayCollection(); @@ -229,4 +234,16 @@ class User implements UserInterface return $this; } + + public function getZipCode(): ?int + { + return $this->zipCode; + } + + public function setZipCode(?int $zipCode): self + { + $this->zipCode = $zipCode; + + return $this; + } } diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php index 7ba7b31..0c80292 100644 --- a/src/Form/RegistrationFormType.php +++ b/src/Form/RegistrationFormType.php @@ -20,6 +20,7 @@ class RegistrationFormType extends AbstractType $builder ->add('email', EmailType::class) ->add('username') + ->add('zipcode') ->add('agreeTerms', CheckboxType::class, [ 'mapped' => false, 'constraints' => [ diff --git a/templates/registration/register.html.twig b/templates/registration/register.html.twig index d56d86e..4fb4aab 100644 --- a/templates/registration/register.html.twig +++ b/templates/registration/register.html.twig @@ -12,6 +12,9 @@ {{ form_start(registrationForm) }} {{ form_row(registrationForm.email) }} {{ form_row(registrationForm.username) }} + {{ form_row(registrationForm.zipcode, { + label: 'PLZ' + }) }} {{ form_row(registrationForm.plainPassword, { label: 'Password' }) }} diff --git a/templates/user/index.html.twig b/templates/user/index.html.twig index 22e3f08..ee24a1c 100644 --- a/templates/user/index.html.twig +++ b/templates/user/index.html.twig @@ -30,7 +30,12 @@
- + +
+ +
+ +