add checkin button #25
@ -11,6 +11,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
|
|||||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
|
||||||
|
|
||||||
class TicketCrudController extends AbstractCrudController
|
class TicketCrudController extends AbstractCrudController
|
||||||
@ -22,16 +23,18 @@ class TicketCrudController extends AbstractCrudController
|
|||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
yield ChoiceField::new('type', 'Name')
|
yield ChoiceField::new('type', 'Typ')
|
||||||
->setChoices(TicketData::TYPES);
|
->setChoices(TicketData::TYPES);
|
||||||
|
|
||||||
yield ChoiceField::new('foodType', 'Ernährung')
|
yield ChoiceField::new('foodType', 'Ernährung')
|
||||||
->setChoices(FoodData::TYPES);
|
->setChoices(FoodData::TYPES);
|
||||||
|
|
||||||
yield AssociationField::new('customer', 'Kunde')
|
yield AssociationField::new('customer', 'Käufer')
|
||||||
->setCrudController(CustomerCrudController::class)
|
->setCrudController(CustomerCrudController::class)
|
||||||
->formatValue(fn(Customer $customer) => $customer->getEmail())
|
->formatValue(fn(Customer $customer) => $customer->getEmail())
|
||||||
->hideOnForm();
|
->hideOnForm();
|
||||||
|
|
||||||
|
yield BooleanField::new('checkedIn', '')->setTemplatePath('admin/checked_in.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ class Ticket implements \Stringable
|
|||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
private ?Customer $customer = null;
|
private ?Customer $customer = null;
|
||||||
|
|
||||||
|
#[ORM\Column(options: ['default' => false])]
|
||||||
|
private ?bool $checkedIn = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@ -84,4 +87,16 @@ class Ticket implements \Stringable
|
|||||||
{
|
{
|
||||||
return TicketData::TICKET_DATA[$this->type]['name'];
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
6
templates/admin/checked_in.html.twig
Normal file
6
templates/admin/checked_in.html.twig
Normal 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 %}
|
Loading…
x
Reference in New Issue
Block a user