diff --git a/migrations/Version20240404071550.php b/migrations/Version20240404071550.php new file mode 100644 index 0000000..0b0cbae --- /dev/null +++ b/migrations/Version20240404071550.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE contact ADD phone VARCHAR(255) NOT NULL, ADD category VARCHAR(64) NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE contact DROP phone, DROP category'); + } +} diff --git a/src/Entity/Contact.php b/src/Entity/Contact.php index d56870d..252ad51 100644 --- a/src/Entity/Contact.php +++ b/src/Entity/Contact.php @@ -9,6 +9,10 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Entity(repositoryClass: ContactRepository::class)] class Contact { + public const CATEGORY_MANAGEMENT = 'management'; + public const CATEGORY_HOUSE_MANAGEMENT = 'house_management'; + public const CATEGORY_HR = 'hr'; + #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] @@ -23,6 +27,10 @@ class Contact #[Assert\Email(message: 'Bitte gib eine gültige E-Mail-Adresse an', mode: 'strict')] private ?string $email = null; + #[ORM\Column(length: 255)] + #[Assert\NotBlank(message: 'Bitte gib die Telefonnummer an')] + private ?string $phone = null; + #[ORM\OneToOne(cascade: ['persist', 'remove'], fetch: 'EAGER')] #[Assert\NotNull(message: 'Bitte lade ein Foto hoch')] private ?Upload $photo = null; @@ -30,6 +38,11 @@ class Contact #[ORM\Column(length: 255, nullable: true)] private ?string $destination = null; + #[ORM\Column(length: 64)] + #[Assert\NotBlank(message: 'Bitte wähle die Kategorie')] + #[Assert\Choice(choices: [self::CATEGORY_HOUSE_MANAGEMENT, self::CATEGORY_MANAGEMENT, self::CATEGORY_HR], message: 'Die Kagegorie ist ungültig')] + private ?string $category = null; + #[ORM\OneToOne(mappedBy: 'contact', cascade: ['persist', 'remove'], fetch: 'EXTRA_LAZY')] private ?User $user = null; @@ -67,6 +80,18 @@ class Contact return $this; } + public function getPhone(): ?string + { + return $this->phone; + } + + public function setPhone(?string $phone): static + { + $this->phone = $phone; + + return $this; + } + public function getPhoto(): ?Upload { return $this->photo; @@ -91,6 +116,18 @@ class Contact return $this; } + public function getCategory(): ?string + { + return $this->category; + } + + public function setCategory(?string $category): static + { + $this->category = $category; + + return $this; + } + public function getUser(): ?User { return $this->user; diff --git a/src/Form/ContactType.php b/src/Form/ContactType.php index 00ebbe0..c796356 100644 --- a/src/Form/ContactType.php +++ b/src/Form/ContactType.php @@ -5,6 +5,7 @@ namespace App\Form; use App\Entity\Contact; use App\Model\UploadSessionDto; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; @@ -21,6 +22,17 @@ class ContactType extends AbstractType ->add('email', EmailType::class, [ 'label' => 'E-Mail', ]) + ->add('phone', TextType::class, [ + 'label' => 'Telefon', + ]) + ->add('category', ChoiceType::class, [ + 'label' => 'Kategorie', + 'choices' => [ + 'Reisemanagement' => Contact::CATEGORY_MANAGEMENT, + 'Hausmanagement' => Contact::CATEGORY_HOUSE_MANAGEMENT, + 'Personalplanung' => Contact::CATEGORY_HR, + ], + ]) ->add('destination', TextType::class, [ 'label' => 'Destination', 'required' => false, diff --git a/templates/admin/system/contact/_form.html.twig b/templates/admin/system/contact/_form.html.twig index 37623d4..a470281 100644 --- a/templates/admin/system/contact/_form.html.twig +++ b/templates/admin/system/contact/_form.html.twig @@ -1,7 +1,9 @@ {{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
+ {{ form_row(form.category) }} {{ form_row(form.name) }} {{ form_row(form.email) }} + {{ form_row(form.phone) }} {{ form_row(form.destination) }}