create customer
This commit is contained in:
parent
3d95c321cc
commit
68086941ba
@ -4,16 +4,19 @@ namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Payment;
|
||||
use App\Enum\TicketData;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
|
||||
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\ChoiceField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TelephoneField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
use App\Form\TicketType;
|
||||
|
||||
class CustomerCrudController extends AbstractCrudController
|
||||
{
|
||||
@ -33,8 +36,11 @@ class CustomerCrudController extends AbstractCrudController
|
||||
->formatValue(fn(?Payment $payment) => ($payment?->getTotal() ?? 0.0) . ' €')
|
||||
->hideOnIndex()
|
||||
->hideOnForm();
|
||||
yield CollectionField::new('tickets', 'Tickets')
|
||||
->setTemplatePath('admin/customer_tickets.html.twig')
|
||||
yield CollectionField::new('tickets')
|
||||
->allowAdd()
|
||||
->allowDelete()
|
||||
->setEntryType(TicketType::class)
|
||||
->setFormTypeOptions(['by_reference' => false])
|
||||
->hideOnIndex();
|
||||
}
|
||||
|
||||
@ -44,7 +50,7 @@ class CustomerCrudController extends AbstractCrudController
|
||||
return $actions
|
||||
->add(Crud::PAGE_INDEX, Action::DETAIL)
|
||||
->disable(Action::DELETE)
|
||||
->disable(Action::NEW)
|
||||
->setPermission(Action::NEW, 'ROLE_SUPER_ADMIN')
|
||||
->setPermission(Action::EDIT, 'ROLE_SUPER_ADMIN');
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: CustomerRepository::class)]
|
||||
class Customer
|
||||
class Customer implements \Stringable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
@ -149,4 +149,9 @@ class Customer
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->firstname . ' ' . $this->lastname;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Enum\TicketData;
|
||||
use App\Repository\TicketRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TicketRepository::class)]
|
||||
class Ticket
|
||||
class Ticket implements \Stringable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
@ -78,4 +79,9 @@ class Ticket
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return TicketData::TICKET_DATA[$this->type]['name'];
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class TicketData
|
||||
];
|
||||
|
||||
public const TYPES = [
|
||||
'Ticket' => 1,
|
||||
'All-Inclusive Ticket' => 1,
|
||||
'After-Show Ticket' => 2,
|
||||
'Kind (6-12 Jahre)' => 3,
|
||||
'Kind (0-6 Jahre)' => 4,
|
||||
|
48
src/Form/TicketType.php
Normal file
48
src/Form/TicketType.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Ticket;
|
||||
use App\Enum\FoodData;
|
||||
use App\Enum\TicketData;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class TicketType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('type', ChoiceType::class, [
|
||||
'label' => 'Ticket Type',
|
||||
'choices' => TicketData::TYPES,
|
||||
'row_attr' => [
|
||||
'style' => 'flex: 1;',
|
||||
],
|
||||
])
|
||||
->add('foodType', ChoiceType::class, [
|
||||
'label' => 'Ernährung',
|
||||
'choices' => FoodData::TYPES,
|
||||
'row_attr' => [
|
||||
'style' => 'flex: 1;',
|
||||
],
|
||||
])
|
||||
->add('note', TextType::class, [
|
||||
'label' => 'Notiz',
|
||||
'required' => false,
|
||||
'row_attr' => [
|
||||
'style' => 'flex: 2;',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Ticket::class,
|
||||
]);
|
||||
}
|
||||
}
|
@ -27,7 +27,6 @@ class AdminPanelAuthenticator extends AbstractAuthenticator
|
||||
$data = LoginData::fromRequest($request);
|
||||
|
||||
if ($request->isMethod(Request::METHOD_POST) && (!$data->password || !$data->username)) {
|
||||
dd($data);
|
||||
throw new CustomUserMessageAuthenticationException();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user