src/Admin/RentalPriceAdmin.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Admin;
  4. use App\Entity\RentalPrice;
  5. use Sonata\AdminBundle\Admin\AbstractAdmin;
  6. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  7. use Sonata\AdminBundle\Datagrid\ListMapper;
  8. use Sonata\AdminBundle\Form\FormMapper;
  9. use Sonata\AdminBundle\Show\ShowMapper;
  10. final class RentalPriceAdmin extends AbstractAdmin
  11. {
  12.     protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
  13.     {
  14.         $datagridMapper
  15.             ->add('name')
  16.             ->add('price1h')
  17.             ->add('price6h')
  18.             ->add('price24h')
  19.         ;
  20.     }
  21.     protected function configureListFields(ListMapper $listMapper): void
  22.     {
  23.         $listMapper
  24.             ->add('name')
  25.             ->add('price1h'null, ['label' => '1 час'])
  26.             ->add('price5h'null, ['label' => '5 часов'])
  27.             ->add('price6h'null, ['label' => '6 часов'])
  28.             ->add('price24h'null, ['label' => 'Сутки (24ч)'])
  29.             ->add('price7d'null, ['label' => 'Неделя'])
  30.             ->add('price30d'null, ['label' => '30 дней'])
  31.             ->add('_action'null, [
  32.                 'actions' => [
  33.                     'show' => [],
  34.                     'edit' => [],
  35.                     'delete' => [],
  36.                 ],
  37.             ])
  38.         ;
  39.     }
  40.     protected function configureFormFields(FormMapper $formMapper): void
  41.     {
  42.         $formMapper
  43.             ->with('Название профиля цен')
  44.                 ->add('name'null, [
  45.                     'label' => 'Название (например: SCR 250, Стандарт, Премиум)',
  46.                     'required' => false,
  47.                 ])
  48.             ->end()
  49.             ->with('Цены аренды (BYN)', ['class' => 'col-md-6'])
  50.                 ->add('price1h'null, ['label' => '1 час'])
  51.                 ->add('price5h'null, ['label' => '5 часов (вечер)'])
  52.                 ->add('price6h'null, ['label' => '6 часов'])
  53.                 ->add('price24h'null, ['label' => 'Сутки (24 часа)'])
  54.             ->end()
  55.             ->with('Долгосрочные цены (BYN)', ['class' => 'col-md-6'])
  56.                 ->add('price7d'null, ['label' => 'Неделя (7 дней)'])
  57.                 ->add('price30d'null, ['label' => '30 дней (месяц)'])
  58.             ->end()
  59.         ;
  60.     }
  61.     protected function configureShowFields(ShowMapper $showMapper): void
  62.     {
  63.         $showMapper
  64.             ->add('id')
  65.             ->add('name')
  66.             ->add('price1h')
  67.             ->add('price5h')
  68.             ->add('price6h')
  69.             ->add('price24h')
  70.             ->add('price7d')
  71.             ->add('price30d')
  72.             ->add('motorcycles')
  73.         ;
  74.     }
  75. }