<?php
declare(strict_types=1);
namespace App\Admin;
use App\Entity\RentalPrice;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
final class RentalPriceAdmin extends AbstractAdmin
{
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('name')
->add('price1h')
->add('price6h')
->add('price24h')
;
}
protected function configureListFields(ListMapper $listMapper): void
{
$listMapper
->add('name')
->add('price1h', null, ['label' => '1 час'])
->add('price5h', null, ['label' => '5 часов'])
->add('price6h', null, ['label' => '6 часов'])
->add('price24h', null, ['label' => 'Сутки (24ч)'])
->add('price7d', null, ['label' => 'Неделя'])
->add('price30d', null, ['label' => '30 дней'])
->add('_action', null, [
'actions' => [
'show' => [],
'edit' => [],
'delete' => [],
],
])
;
}
protected function configureFormFields(FormMapper $formMapper): void
{
$formMapper
->with('Название профиля цен')
->add('name', null, [
'label' => 'Название (например: SCR 250, Стандарт, Премиум)',
'required' => false,
])
->end()
->with('Цены аренды (BYN)', ['class' => 'col-md-6'])
->add('price1h', null, ['label' => '1 час'])
->add('price5h', null, ['label' => '5 часов (вечер)'])
->add('price6h', null, ['label' => '6 часов'])
->add('price24h', null, ['label' => 'Сутки (24 часа)'])
->end()
->with('Долгосрочные цены (BYN)', ['class' => 'col-md-6'])
->add('price7d', null, ['label' => 'Неделя (7 дней)'])
->add('price30d', null, ['label' => '30 дней (месяц)'])
->end()
;
}
protected function configureShowFields(ShowMapper $showMapper): void
{
$showMapper
->add('id')
->add('name')
->add('price1h')
->add('price5h')
->add('price6h')
->add('price24h')
->add('price7d')
->add('price30d')
->add('motorcycles')
;
}
}