You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.9KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\User;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  6. use Lc\CaracoleBundle\Context\MerchantContextTrait;
  7. use Lc\CaracoleBundle\Field\AssociationField;
  8. use Lc\CaracoleBundle\Field\Filter\User\UserMerchantEmailFilter;
  9. use Lc\CaracoleBundle\Field\Filter\User\UserMerchantFirstnameFilter;
  10. use Lc\CaracoleBundle\Field\Filter\User\UserMerchantLastnameFilter;
  11. use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
  12. class UserMerchantFieldDefinition extends AbstractFieldDefinition
  13. {
  14. use MerchantContextTrait;
  15. public function configureIndex(): array
  16. {
  17. return [
  18. 'id',
  19. 'lastname',
  20. 'firstname',
  21. 'email',
  22. 'credit',
  23. ];
  24. }
  25. public function configureForm(): array
  26. {
  27. return [
  28. 'user',
  29. ];
  30. }
  31. public function configureFields(): array
  32. {
  33. return [
  34. 'id'=> IntegerField::new('id')->onlyOnIndex()->setSortable(true),
  35. 'lastname'=> TextField::new('user.lastname')->setSortable(true)
  36. ->setCustomOption('filter_fqcn', UserMerchantLastnameFilter::class),
  37. 'firstname'=> TextField::new('user.firstname')->setSortable(true)
  38. ->setCustomOption('filter_fqcn', UserMerchantFirstnameFilter::class),
  39. 'email'=> TextField::new('user.email')->setSortable(true)
  40. ->setCustomOption('filter_fqcn', UserMerchantEmailFilter::class),
  41. 'credit'=> NumberField::new('credit')->setSortable(true)
  42. ->setTemplatePath('@LcSov/adminlte/crud/field/amount.html.twig')
  43. ->setCustomOption('appendHtml', '&euro;'),
  44. 'user'=> AssociationField::new('user'),
  45. ];
  46. }
  47. }