src/Entity/News.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\NewsRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Metadata\Get;
  10. use ApiPlatform\Metadata\Post;
  11. use ApiPlatform\Metadata\Put;
  12. use ApiPlatform\Metadata\Delete;
  13. use ApiPlatform\Metadata\ApiFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. #[ORM\Entity(repositoryClassNewsRepository::class)]
  17. // #[Get]
  18. // #[Put(security: "is_granted('ROLE_ADMIN')")]
  19. // #[Post(security: "is_granted('ROLE_ADMIN')")]
  20. // #[Delete(security: "is_granted('ROLE_ADMIN')")]
  21. #[ApiResource(
  22.     normalizationContext: ['groups' => ['news:read']],
  23.     denormalizationContext: ['groups' => ['news:write']],
  24.     order: ['id' => 'DESC'], paginationClientItemsPerPagetrue
  25.     )
  26. ]
  27. #[ApiFilter(SearchFilter::class, properties: ['categories.id' => 'exact''name' => 'ipartial', ])]
  28. class News
  29. {
  30.     #[Groups(['news:read''news:write'])]
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     private ?int $id null;
  35.     #[Groups(['news:read''news:write'])]
  36.     #[ORM\Column(length255)]
  37.     private ?string $name null;
  38.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  39.     #[Groups(['news:read''news:write'])]
  40.     private ?\DateTimeInterface $date null;
  41.     #[Groups(['news:read''news:write'])]
  42.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  43.     private ?string $newsShot null;
  44.     #[Groups(['news:read''news:write'])]
  45.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  46.     private ?string $newsFull null;
  47.     #[Groups(['news:read''news:write'])]
  48.     #[ORM\Column(length2nullabletrue)]
  49.     private ?string $active null;
  50.     #[Groups(['news:read''news:write'])]
  51.     #[ORM\Column(length2nullabletrue)]
  52.     private ?string $top null;
  53.     #[Groups(['news:read''news:write'])]
  54.     #[ORM\Column(length255nullabletrue)]
  55.     private ?string $audio_link null;
  56.     #[Groups(['news:read''news:write'])]
  57.     #[ORM\Column(length255nullabletrue)]
  58.     private ?string $video_link null;
  59.     #[Groups(['news:read''news:write'])]
  60.     #[ORM\Column(length255nullabletrue)]
  61.     private ?string $audio_title null;
  62.     #[Groups(['news:read''news:write'])]
  63.     #[ORM\Column(length2nullabletrue)]
  64.     private ?string $audio_active null;
  65.     #[Groups(['news:read''news:write'])]
  66.     #[ORM\Column(length255nullabletrue)]
  67.     private ?string $video_img null;
  68.     #[ORM\Column(length255nullabletrue)]
  69.     private ?string $slider null;
  70.     #[ORM\Column(length255nullabletrue)]
  71.     private ?string $dateStart null;
  72.     #[ORM\Column(length255nullabletrue)]
  73.     private ?string $address null;
  74.     #[ORM\Column(length255nullabletrue)]
  75.     private ?string $shortDescription null;
  76.     #[ORM\Column(length255nullabletrue)]
  77.     private ?string $contentImg null;
  78.     #[Groups(['news:read''news:write'])]
  79.     #[ORM\ManyToMany(targetEntityCategory::class, mappedBy'news')]
  80.     private Collection $categories;
  81.     #[Groups(['news:read''news:write'])]
  82.     #[ORM\ManyToOne(inversedBy'news')]
  83.     private ?MediaObject $media null
  84.     public function __construct() 
  85.     {
  86.         $this->categories = new ArrayCollection();
  87.     }
  88.     public function getId(): ?int
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getName(): ?string
  93.     {
  94.         return $this->name;
  95.     }
  96.     public function setName(string $name): self
  97.     {
  98.         $this->name $name;
  99.         return $this;
  100.     }
  101.     public function getDate(): ?\DateTimeInterface
  102.     {
  103.         return $this->date;
  104.     }
  105.     public function setDate(\DateTimeInterface $date): self
  106.     {
  107.         $this->date $date;
  108.         return $this;
  109.     }
  110.     public function getNewsShot(): ?string
  111.     {
  112.         return $this->newsShot;
  113.     }
  114.     public function setNewsShot(?string $newsShot): self
  115.     {
  116.         $this->newsShot $newsShot;
  117.         return $this;
  118.     }
  119.     public function getNewsFull(): ?string
  120.     {
  121.         return $this->newsFull;
  122.     }
  123.     public function setNewsFull(?string $newsFull): self
  124.     {
  125.         $this->newsFull $newsFull;
  126.         return $this;
  127.     }
  128.     public function getActive(): ?string
  129.     {
  130.         return $this->active;
  131.     }
  132.     public function setActive(string $active): self
  133.     {
  134.         $this->active $active;
  135.         return $this;
  136.     }
  137.     public function getTop(): ?string
  138.     {
  139.         return $this->top;
  140.     }
  141.     public function setTop(?string $top): self
  142.     {
  143.         $this->top $top;
  144.         return $this;
  145.     }
  146.     public function getAudioLink(): ?string
  147.     {
  148.         return $this->audio_link;
  149.     }
  150.     public function setAudioLink(?string $audio_link): self
  151.     {
  152.         $this->audio_link $audio_link;
  153.         return $this;
  154.     }
  155.     public function getVideoLink(): ?string
  156.     {
  157.         return $this->video_link;
  158.     }
  159.     public function setVideoLink(?string $video_link): self
  160.     {
  161.         $this->video_link $video_link;
  162.         return $this;
  163.     }
  164.     public function getAudioTitle(): ?string
  165.     {
  166.         return $this->audio_title;
  167.     }
  168.     public function setAudioTitle(?string $audio_title): self
  169.     {
  170.         $this->audio_title $audio_title;
  171.         return $this;
  172.     }
  173.     public function getAudioActive(): ?string
  174.     {
  175.         return $this->audio_active;
  176.     }
  177.     public function setAudioActive(?string $audio_active): self
  178.     {
  179.         $this->audio_active $audio_active;
  180.         return $this;
  181.     }
  182.     public function getVideoImg(): ?string
  183.     {
  184.         return $this->video_img;
  185.     }
  186.     public function setVideoImg(?string $video_img): self
  187.     {
  188.         $this->video_img $video_img;
  189.         return $this;
  190.     }
  191.     public function getSlider(): ?string
  192.     {
  193.         return $this->slider;
  194.     }
  195.     public function setSlider(?string $slider): static
  196.     {
  197.         $this->slider $slider;
  198.         
  199.         return $this;
  200.     }
  201.     /**
  202.      * @return Collection<int, Category>
  203.      */
  204.     public function getCategories(): Collection
  205.     {
  206.         return $this->categories;
  207.     }
  208.     public function addCategory(Category $category): static
  209.     {
  210.         if (!$this->categories->contains($category)) {
  211.             $this->categories->add($category);
  212.             $category->addNews($this);
  213.         }
  214.         return $this;
  215.     }
  216.     public function getDateStart(): ?string
  217.     {
  218.         return $this->dateStart;
  219.     }
  220.     public function setDateStart(?string $dateStart): static
  221.     {
  222.         $this->dateStart $dateStart;
  223.         return $this;
  224.     }
  225.     public function getAddress(): ?string
  226.     {
  227.         return $this->address;
  228.     }
  229.     public function setAddress(?string $address): static
  230.     {
  231.         $this->address $address;
  232.         return $this;
  233.     }
  234.     public function getShortDescription(): ?string
  235.     {
  236.         return $this->shortDescription;
  237.     }
  238.     public function setShortDescription(?string $shortDescription): static
  239.     {
  240.         $this->shortDescription $shortDescription;
  241.         return $this;
  242.     }
  243.     public function getContentImg(): ?string
  244.     {
  245.         return $this->contentImg;
  246.     }
  247.     public function setContentImg(?string $contentImg): static
  248.     {
  249.         $this->contentImg $contentImg;
  250.         
  251.         return $this;
  252.     }
  253.     public function removeCategory(Category $category): static
  254.     {
  255.         if ($this->categories->removeElement($category)) {
  256.             $category->removeNews($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function getMedia(): ?MediaObject
  261.     {
  262.         return $this->media;
  263.     }
  264.     public function setMedia(?MediaObject $media): static
  265.     {
  266.         $this->media $media;
  267.         return $this;
  268.     }
  269. }