src/Admin/ServicoAdmin.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Admin;
  4. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  5. use Sonata\AdminBundle\Datagrid\ListMapper;
  6. use Sonata\AdminBundle\Form\FormMapper;
  7. use Sonata\AdminBundle\Show\ShowMapper;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Component\Form\Extension\Core\Type\MoneyType;
  11. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  12. final class ServicoAdmin extends BaseAdmin
  13. {
  14.     protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
  15.     {
  16.         $datagridMapper
  17.             ->add('id')
  18.             ->add('tipo')
  19.             ->add('titulo')
  20.             ->add('valor')
  21.             ->add('createdAt')
  22.             ->add('updatedAt')
  23.             ;
  24.     }
  25.     protected function configureListFields(ListMapper $listMapper): void
  26.     {
  27.         $listMapper
  28.             ->add('id')
  29.             ->add('tipo')
  30.             ->add('titulo')
  31.             ->add('valor')
  32.             ->add('createdAt'null, ['label'=>'Dta. cadastro'])
  33.             ->add('_action'null, [
  34.                 'actions' => [
  35.                     'show' => [],
  36.                     'edit' => [],
  37.                     'delete' => [],
  38.                 ],
  39.             ]);
  40.     }
  41.     protected function configureFormFields(FormMapper $formMapper): void
  42.     {
  43.         $formMapper
  44.             ->add('tipo'ChoiceType::class, [
  45.                 'choices' => [
  46.                     'Selecione' => '',
  47.                     'Amostra' => 'amostra',
  48.                     'Corpo de Prova' => 'cp',
  49.                     'Diária' => 'diaria',
  50.                     'Mensal' => 'mensal',
  51.                     'Verba' => 'verba',
  52.                     'Metro' => 'metro',
  53.                     'Visita' => 'visita',
  54.                     'Hora' => 'hora',
  55.                     'Relatório' => 'relatorio',
  56.                     'Pessoa' => 'pessoa',
  57.                     'M³' => 'metro_3',
  58.                 ]
  59.             ])
  60.             ->add('titulo')
  61.             ->add('valor'MoneyType::class, [
  62.                 'label' => 'Valor',
  63.                 'currency' => 'BRL',
  64.                 'grouping' => true,
  65.                 'attr' => ['class' => 'maskMoney'],
  66.             ])
  67.             ;
  68.     }
  69.     protected function configureShowFields(ShowMapper $showMapper): void
  70.     {
  71.         $showMapper
  72.             ->add('id')
  73.             ->add('tipo')
  74.             ->add('titulo')
  75.             ->add('valor')
  76.             ->add('createdAt'null, ['label'=>'Dta. cadastro'])
  77.             ->add('updatedAt'null, ['label'=>'Dta. alteração'])
  78.             ;
  79.     }
  80. }