src/Containers/SettingSection/ListContainer/Entities/MessageMileageBalanceEntity.php line 67

Open in your IDE?
  1. <?php
  2. namespace App\Containers\SettingSection\ListContainer\Entities;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Patch;
  8. use ApiPlatform\Metadata\Put;
  9. use ApiPlatform\Metadata\Post;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  13. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\DBAL\Types\Types;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use App\Containers\SettingSection\ListContainer\Data\Repositories\MessageMileageBalanceRepository;
  20. use App\Containers\SettingSection\IndexContainer\Entities\TranslationEntity;
  21. use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
  22. /** 
  23.  * Сообщения баланса пробега
  24. */
  25. #[ApiResource(
  26.     routePrefix'/list',
  27.     normalizationContext: ['groups' => 'read'],
  28.     operations: [
  29.         new Get(
  30.             uriTemplate'/messages_mileage_balance/{id}'requirements: ['id' => '\d+'],
  31.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  32.         ),
  33.         new Patch(
  34.             uriTemplate'/messages_mileage_balance/{id}'requirements: ['id' => '\d+'],
  35.             security"is_granted('ROLE_ADMIN')"
  36.         ),
  37.         // new Put(
  38.         //     uriTemplate: '/messages_mileage_balance/{id}', requirements: ['id' => '\d+'],
  39.         //     security: "is_granted('ROLE_ADMIN')"
  40.         // ),
  41.         new Delete(
  42.             uriTemplate'/messages_mileage_balance/{id}'requirements: ['id' => '\d+'],
  43.             security"is_granted('ROLE_ADMIN')"
  44.         ),
  45.         new Post(
  46.             uriTemplate'/messages_mileage_balance',
  47.             security"is_granted('ROLE_ADMIN')"
  48.         ),
  49.         new GetCollection(
  50.             uriTemplate'/messages_mileage_balance',
  51.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  52.         ),
  53.     ],
  54.     shortName'List_MessagesMileageBalance'
  55. )]
  56. #[ApiFilter(SearchFilter::class, properties: ['id' => 'exact''name' => 'partial''externalCode' => 'partial''message' => 'partial'])]
  57. #[ApiFilter(NumericFilter::class, properties: ['id''mileageFrom''mileageTo'])]
  58. #[ApiFilter(RangeFilter::class, properties: ['id'])]
  59. #[ApiFilter(OrderFilter::class)]
  60. #[ApiFilter(filterClassSimpleSearchFilter::class, properties: ['name''externalCode''message'])]
  61. #[ORM\Entity(repositoryClassMessageMileageBalanceRepository::class)]
  62. #[ORM\Table(name'`list_messages_mileage_balance`')]
  63. #[Gedmo\TranslationEntity(class: TranslationEntity::class)]
  64. class MessageMileageBalanceEntity
  65. {   
  66.     #[ORM\Id]
  67.     #[ORM\GeneratedValue]
  68.     #[ORM\Column(typeTypes::INTEGER)]
  69.     #[Groups(['read'])]
  70.     private ?int $id null;
  71.     // Название
  72.     #[ORM\Column(typeTypes::STRINGlength255)]
  73.     #[Gedmo\Translatable]
  74.     #[Groups(['read'])]
  75.     private string $name;
  76.     #[ORM\Column(typeTypes::STRINGlength255nullabletrueuniquetrue)]
  77.     #[Groups(['read'])]
  78.     private ?string $externalCode null;
  79.     // Сортування
  80.     #[ORM\Column(typeTypes::INTEGERlength10options: ['default' => 500])]
  81.     #[Groups(['read'])]
  82.     private ?int $sorting 500;
  83.     // Активность
  84.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => true])]
  85.     #[Groups(['read'])]
  86.     private bool $isActive true;
  87.     // Всегда отправлять (независимо от настроек пользователя)
  88.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  89.     #[Groups(['read'])]
  90.     private bool $isAlwaysSend false;
  91.     // Пробег от
  92.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  93.     #[Groups(['read'])]
  94.     private int $mileageFrom 0;
  95.     // Пробег до
  96.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  97.     #[Groups(['read'])]
  98.     private int $mileageTo 0;
  99.     // Заголовок сообщения
  100.     #[ORM\Column(typeTypes::STRINGlength255nullabletrue)]
  101.     #[Gedmo\Translatable]
  102.     #[Groups(['read'])]
  103.     private ?string $title null;
  104.     // Текст сообщения
  105.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  106.     #[Gedmo\Translatable]
  107.     #[Groups(['read'])]
  108.     private ?string $message null;
  109.     #[Gedmo\Timestampable(on'create')]
  110.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  111.     protected $createdAt;
  112.     #[Gedmo\Timestampable(on'update')]
  113.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  114.     protected $updatedAt;
  115.     /**
  116.      * Used locale to override Translation listener`s locale
  117.      * this is not a mapped field of entity metadata, just a simple property
  118.      */
  119.     #[Gedmo\Locale]
  120.     private $locale;
  121.     public function getId(): ?int
  122.     {
  123.         return $this->id;
  124.     }
  125.     public function getName()
  126.     {
  127.         return $this->name;
  128.     }
  129.     public function setName($name)
  130.     {
  131.         $this->name $name;
  132.         return $this;
  133.     }
  134.     public function getExternalCode()
  135.     {
  136.         return $this->externalCode;
  137.     }
  138.  
  139.     public function setExternalCode($code)
  140.     {
  141.         $this->externalCode $code;
  142.         return $this;
  143.     }
  144.     public function getSorting()
  145.     {
  146.         return $this->sorting;
  147.     }
  148.     public function setSorting($sorting)
  149.     {
  150.         $this->sorting $sorting;
  151.         return $this;
  152.     }
  153.     public function getIsActive()
  154.     {
  155.         return $this->isActive;
  156.     }
  157.     public function setIsActive($isActive)
  158.     {
  159.         $this->isActive $isActive;
  160.         return $this;
  161.     }
  162.     public function getIsAlwaysSend()
  163.     {
  164.         return $this->isAlwaysSend;
  165.     }
  166.     public function setIsAlwaysSend($isAlwaysSend)
  167.     {
  168.         $this->isAlwaysSend $isAlwaysSend;
  169.         return $this;
  170.     }
  171.     public function getMileageFrom()
  172.     {
  173.         return $this->mileageFrom;
  174.     }
  175.     public function setMileageFrom($value)
  176.     {
  177.         $this->mileageFrom $value;
  178.         return $this;
  179.     }
  180.     public function getMileageTo()
  181.     {
  182.         return $this->mileageTo;
  183.     }
  184.     public function setMileageTo($value)
  185.     {
  186.         $this->mileageTo $value;
  187.         return $this;
  188.     }
  189.     public function getTitle()
  190.     {
  191.         return $this->title;
  192.     }
  193.     public function setTitle($title)
  194.     {
  195.         $this->title $title;
  196.         return $this;
  197.     }
  198.     public function getMessage()
  199.     {
  200.         return $this->message;
  201.     }
  202.     public function setMessage($text)
  203.     {
  204.         $this->message $text;
  205.         return $this;
  206.     }
  207.     public function setTranslatableLocale($locale)
  208.     {
  209.         $this->locale $locale;
  210.     }
  211. }