From dfcdfc07ccad0b200af1e377925cac63dc829853 Mon Sep 17 00:00:00 2001 From: Constantin Simonis Date: Mon, 3 Mar 2025 21:39:17 +0100 Subject: [PATCH] delete customers --- src/Controller/Admin/CustomerCrudController.php | 6 +++++- src/Entity/Customer.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Controller/Admin/CustomerCrudController.php b/src/Controller/Admin/CustomerCrudController.php index 8f4a91b..d7ba0a4 100644 --- a/src/Controller/Admin/CustomerCrudController.php +++ b/src/Controller/Admin/CustomerCrudController.php @@ -40,6 +40,10 @@ class CustomerCrudController extends AbstractCrudController ->setFormTypeOptions(['by_reference' => false]) ->setTemplatePath('admin/customer_tickets.html.twig') ->hideOnIndex(); + yield AssociationField::new('payment', 'Zahlungs Status') + ->setCrudController(PaymentCrudController::class) + ->hideOnForm() + ->formatValue(fn(?Payment $payment) => $payment?->isCompleted() ? 'Bezahlt' : 'Offen'); } @@ -47,7 +51,7 @@ class CustomerCrudController extends AbstractCrudController { return $actions ->add(Crud::PAGE_INDEX, Action::DETAIL) - ->disable(Action::DELETE) + ->setPermission(Action::DELETE, 'ROLE_SUPER_ADMIN') ->setPermission(Action::NEW, 'ROLE_SUPER_ADMIN') ->setPermission(Action::EDIT, 'ROLE_SUPER_ADMIN'); } diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 0101701..b19ac8e 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -30,7 +30,7 @@ class Customer implements \Stringable /** * @var Collection */ - #[ORM\OneToMany(targetEntity: Ticket::class, mappedBy: 'customer', cascade: ['persist'], fetch: 'EAGER', orphanRemoval: true)] + #[ORM\OneToMany(targetEntity: Ticket::class, mappedBy: 'customer', cascade: ['persist', 'remove'], fetch: 'EAGER', orphanRemoval: true)] private Collection $tickets; #[ORM\OneToOne(mappedBy: 'customer', cascade: ['persist', 'remove'])] -- 2.47.2