From deeadda31508b3780eaf091a687c88b569265410 Mon Sep 17 00:00:00 2001 From: Constantin Simonis Date: Thu, 13 Feb 2025 21:59:10 +0100 Subject: [PATCH] wip --- src/Controller/Admin/TicketCrudController.php | 7 +++++-- src/Entity/Ticket.php | 15 +++++++++++++++ templates/admin/checked_in.html.twig | 6 ++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 templates/admin/checked_in.html.twig diff --git a/src/Controller/Admin/TicketCrudController.php b/src/Controller/Admin/TicketCrudController.php index a61dc3e..1b87949 100644 --- a/src/Controller/Admin/TicketCrudController.php +++ b/src/Controller/Admin/TicketCrudController.php @@ -11,6 +11,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; class TicketCrudController extends AbstractCrudController @@ -22,16 +23,18 @@ class TicketCrudController extends AbstractCrudController public function configureFields(string $pageName): iterable { - yield ChoiceField::new('type', 'Name') + yield ChoiceField::new('type', 'Typ') ->setChoices(TicketData::TYPES); yield ChoiceField::new('foodType', 'Ernährung') ->setChoices(FoodData::TYPES); - yield AssociationField::new('customer', 'Kunde') + yield AssociationField::new('customer', 'Käufer') ->setCrudController(CustomerCrudController::class) ->formatValue(fn(Customer $customer) => $customer->getEmail()) ->hideOnForm(); + + yield BooleanField::new('checkedIn', '')->setTemplatePath('admin/checked_in.html.twig'); } diff --git a/src/Entity/Ticket.php b/src/Entity/Ticket.php index 914c208..2fa1358 100644 --- a/src/Entity/Ticket.php +++ b/src/Entity/Ticket.php @@ -27,6 +27,9 @@ class Ticket implements \Stringable #[ORM\JoinColumn(nullable: false)] private ?Customer $customer = null; + #[ORM\Column(options: ['default' => false])] + private ?bool $checkedIn = null; + public function getId(): ?int { return $this->id; @@ -84,4 +87,16 @@ class Ticket implements \Stringable { return TicketData::TICKET_DATA[$this->type]['name']; } + + public function isCheckedIn(): ?bool + { + return $this->checkedIn; + } + + public function setCheckedIn(bool $checkedIn): static + { + $this->checkedIn = $checkedIn; + + return $this; + } } diff --git a/templates/admin/checked_in.html.twig b/templates/admin/checked_in.html.twig new file mode 100644 index 0000000..ca79db0 --- /dev/null +++ b/templates/admin/checked_in.html.twig @@ -0,0 +1,6 @@ +{% if not field.value %} + + {{ dump(field) }} +{% else %} + +{% endif %} \ No newline at end of file