src/Entity/Blog.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlogRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\String\Slugger\AsciiSlugger;
  9. #[ORM\Entity(repositoryClassBlogRepository::class)]
  10. #[ORM\Index(name"url_idx"columns: ["url"])]
  11. class Blog
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\ManyToMany(targetEntityBlogKind::class, inversedBy'blogs')]
  18.     private Collection $kinds;
  19.     #[ORM\ManyToOne]
  20.     private ?BlogKind $mainKind null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $name null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?string $url null;
  25.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  26.     private ?string $description null;
  27.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  28.     private ?string $text null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $keyword null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $textSource null;
  33.     #[ORM\Column]
  34.     private ?bool $visible null;
  35.     #[ORM\Column]
  36.     private ?bool $visibleHomepage null;
  37.     #[ORM\Column]
  38.     private ?\DateTime $createAt null;
  39.     #[ORM\ManyToOne(inversedBy'blogs')]
  40.     private ?VehicleManufacturer $vehicleManufacturer null;
  41.     #[ORM\ManyToOne(inversedBy'blogs')]
  42.     private ?VehicleModel $vehicleModel null;
  43.     #[ORM\Column(nullabletrue)]
  44.     private ?int $importId null;
  45.     #[ORM\OrderBy(['main' => 'DESC''id' => 'ASC'])]
  46.     #[ORM\OneToMany(mappedBy'blog'targetEntityBlogImage::class, cascade: ['persist''remove'])]
  47.     private Collection $blogImages;
  48.     #[ORM\Column(nullabletrue)]
  49.     private ?bool $top null;
  50.     #[ORM\Column(length255nullabletrue)]
  51.     private ?string $redirect null;
  52.     public function __construct()
  53.     {
  54.         $this->kinds = new ArrayCollection();
  55.         $this->blogImages = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     /**
  62.      * @return Collection<int, BlogKind>
  63.      */
  64.     public function getKinds(): Collection
  65.     {
  66.         return $this->kinds;
  67.     }
  68.     public function addKind(BlogKind $kind): self
  69.     {
  70.         if (!$this->kinds->contains($kind)) {
  71.             $this->kinds->add($kind);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeKind(BlogKind $kind): self
  76.     {
  77.         $this->kinds->removeElement($kind);
  78.         return $this;
  79.     }
  80.     public function getMainKind(): ?BlogKind
  81.     {
  82.         return $this->mainKind;
  83.     }
  84.     public function setMainKind(?BlogKind $mainKind): self
  85.     {
  86.         $this->mainKind $mainKind;
  87.         return $this;
  88.     }
  89.     public function getName(): ?string
  90.     {
  91.         return $this->name;
  92.     }
  93.     public function setName(string $name): self
  94.     {
  95.         $this->name $name;
  96.         return $this;
  97.     }
  98.     public function getUrl(): ?string
  99.     {
  100.         return $this->url;
  101.     }
  102.     public function setUrl(?string $url): self
  103.     {
  104.         if($url) {
  105.             $slugger = new AsciiSlugger('cs');
  106.             $slug =   $slugger->slug($url'-')->lower();
  107.             $this->url $slug->toString();
  108.         } else {
  109.             $this->url null;
  110.         }
  111.         return $this;
  112.     }
  113.     public function getDescription(): ?string
  114.     {
  115.         return $this->description;
  116.     }
  117.     public function setDescription(?string $description): self
  118.     {
  119.         $this->description $description;
  120.         return $this;
  121.     }
  122.     public function getText(): ?string
  123.     {
  124.         return $this->text;
  125.     }
  126.     public function setText(?string $text): self
  127.     {
  128.         $this->text $text;
  129.         return $this;
  130.     }
  131.     public function getKeyword(): ?string
  132.     {
  133.         return $this->keyword;
  134.     }
  135.     public function setKeyword(?string $keyword): self
  136.     {
  137.         $this->keyword $keyword;
  138.         return $this;
  139.     }
  140.     public function getTextSource(): ?string
  141.     {
  142.         return $this->textSource;
  143.     }
  144.     public function setTextSource(?string $textSource): self
  145.     {
  146.         $this->textSource $textSource;
  147.         return $this;
  148.     }
  149.     public function isVisible(): ?bool
  150.     {
  151.         return $this->visible;
  152.     }
  153.     public function setVisible(bool $visible): self
  154.     {
  155.         $this->visible $visible;
  156.         return $this;
  157.     }
  158.     public function isVisibleHomepage(): ?bool
  159.     {
  160.         return $this->visibleHomepage;
  161.     }
  162.     public function setVisibleHomepage(bool $visibleHomepage): self
  163.     {
  164.         $this->visibleHomepage $visibleHomepage;
  165.         return $this;
  166.     }
  167.     public function getCreateAt(): ?\DateTime
  168.     {
  169.         return $this->createAt;
  170.     }
  171.     public function setCreateAt(\DateTime  $createAt): self
  172.     {
  173.         $this->createAt $createAt;
  174.         return $this;
  175.     }
  176.     public function getVehicleManufacturer(): ?VehicleManufacturer
  177.     {
  178.         return $this->vehicleManufacturer;
  179.     }
  180.     public function setVehicleManufacturer(?VehicleManufacturer $vehicleManufacturer): self
  181.     {
  182.         $this->vehicleManufacturer $vehicleManufacturer;
  183.         return $this;
  184.     }
  185.     public function getVehicleModel(): ?VehicleModel
  186.     {
  187.         return $this->vehicleModel;
  188.     }
  189.     public function setVehicleModel(?VehicleModel $vehicleModel): self
  190.     {
  191.         $this->vehicleModel $vehicleModel;
  192.         return $this;
  193.     }
  194.     public function getImportId(): ?int
  195.     {
  196.         return $this->importId;
  197.     }
  198.     public function setImportId(?int $importId): self
  199.     {
  200.         $this->importId $importId;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection<int, BlogImage>
  205.      */
  206.     public function getBlogImages(): Collection
  207.     {
  208.         return $this->blogImages;
  209.     }
  210.     public function addBlogImage(BlogImage $blogImage): self
  211.     {
  212.         if (!$this->blogImages->contains($blogImage)) {
  213.             $this->blogImages->add($blogImage);
  214.             $blogImage->setBlog($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removeBlogImage(BlogImage $blogImage): self
  219.     {
  220.         if ($this->blogImages->removeElement($blogImage)) {
  221.             // set the owning side to null (unless already changed)
  222.             if ($blogImage->getBlog() === $this) {
  223.                 $blogImage->setBlog(null);
  224.             }
  225.         }
  226.         return $this;
  227.     }
  228.     public function isTop(): ?bool
  229.     {
  230.         return $this->top;
  231.     }
  232.     public function setTop(?bool $top): self
  233.     {
  234.         $this->top $top;
  235.         return $this;
  236.     }
  237.     public function getRedirect(): ?string
  238.     {
  239.         return $this->redirect;
  240.     }
  241.     public function setRedirect(?string $redirect): self
  242.     {
  243.         $this->redirect $redirect;
  244.         return $this;
  245.     }
  246. }