This commit is contained in:
Constantin Simonis 2025-02-13 21:59:10 +01:00
parent 3b8b099ae9
commit deeadda315
Signed by: csimonis
GPG Key ID: 3878FF77C24AF4D2
3 changed files with 26 additions and 2 deletions

View File

@ -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');
}

View File

@ -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;
}
}

View File

@ -0,0 +1,6 @@
{% if not field.value %}
<button data-controller="checkin" data-id="">Einchecken</button>
{{ dump(field) }}
{% else %}
<button disabled>Eingechecked</button>
{% endif %}