src/Entity/Gos/Uniqskills/Testimonial.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills;
  3. use App\Entity\Gos\Category;
  4. use App\Entity\Gos\Language;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Table()
  14.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\TestimonialRepository")
  15.  * @Vich\Uploadable
  16.  * @ORM\HasLifecycleCallbacks
  17.  */
  18. class Testimonial
  19. {
  20.     /**
  21.      * @ORM\Column(type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="IDENTITY")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="boolean", nullable=true)
  28.      */
  29.     private $isActive;
  30.     /**
  31.      * @ORM\Column(type="boolean", nullable=true)
  32.      */
  33.     private $onMainPage;
  34.     /**
  35.      * @Assert\NotBlank()
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $name;
  39.     /**
  40.      * @Gedmo\Slug(fields={"name"})
  41.      * @ORM\Column(type="string", length=191, unique=true)
  42.      */
  43.     private $slug;
  44.     /**
  45.      * @Assert\NotBlank()
  46.      * @ORM\Column(type="text", nullable=true)
  47.      */
  48.     private $content;
  49.     /**
  50.      * @Assert\NotBlank()
  51.      * @ORM\Column(type="text", nullable=true)
  52.      */
  53.     private $achievement;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity="App\Entity\Gos\Language")
  56.      * @ORM\JoinColumn()
  57.      */
  58.     private $language;
  59.     /**
  60.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Category")
  61.      * @ORM\JoinTable(name="testimonial_category",
  62.      *      joinColumns={@ORM\JoinColumn(name="testimonial_id", referencedColumnName="id")},
  63.      *      inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")}
  64.      *      )
  65.      */
  66.     private $categories;
  67.     /**
  68.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  69.      *
  70.      * @Assert\File(
  71.      * maxSize="1M",
  72.      * mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}
  73.      * )
  74.      * @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
  75.      *
  76.      * @var File
  77.      */
  78.     private $imageFile;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      *
  82.      * @var string
  83.      */
  84.     private $imageName;
  85.     /**
  86.      * @ORM\Column(type="datetime")
  87.      */
  88.     private $createdAt;
  89.     /**
  90.      * @ORM\Column(type="datetime", nullable=true)
  91.      *
  92.      * @var \DateTime
  93.      */
  94.     private $updatedAt;
  95.     public function __construct()
  96.     {
  97.         $this->categories = new ArrayCollection();
  98.     }
  99.     /**
  100.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  101.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  102.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  103.      * must be able to accept an instance of 'File' as the bundle will inject one here
  104.      * during Doctrine hydration.
  105.      *
  106.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  107.      *
  108.      * @return Testimonial
  109.      */
  110.     public function setImageFile(File $image null)
  111.     {
  112.         $this->imageFile $image;
  113.         if ($image) {
  114.             // It is required that at least one field changes if you are using doctrine
  115.             // otherwise the event listeners won't be called and the file is lost
  116.             $this->updatedAt = new \DateTimeImmutable();
  117.         }
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return File|null
  122.      */
  123.     public function getImageFile()
  124.     {
  125.         return $this->imageFile;
  126.     }
  127.     /**
  128.      * @param string $imageName
  129.      *
  130.      * @return Testimonial
  131.      */
  132.     public function setImageName($imageName)
  133.     {
  134.         $this->imageName $imageName;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return string|null
  139.      */
  140.     public function getImageName()
  141.     {
  142.         return $this->imageName;
  143.     }
  144.     /** @ORM\PrePersist() */
  145.     public function prePersist()
  146.     {
  147.         $this->createdAt = new \DateTime();
  148.     }
  149.     /** @ORM\PreUpdate() */
  150.     public function preUpdate()
  151.     {
  152.         $this->updatedAt = new \DateTime();
  153.     }
  154.     public function __toString()
  155.     {
  156.         return (string)$this->name;
  157.     }
  158.     public function getId(): ?int
  159.     {
  160.         return $this->id;
  161.     }
  162.     public function getIsActive(): ?bool
  163.     {
  164.         return $this->isActive;
  165.     }
  166.     public function setIsActive(?bool $isActive): self
  167.     {
  168.         $this->isActive $isActive;
  169.         return $this;
  170.     }
  171.     public function getOnMainPage(): ?bool
  172.     {
  173.         return $this->onMainPage;
  174.     }
  175.     public function setOnMainPage(?bool $onMainPage): self
  176.     {
  177.         $this->onMainPage $onMainPage;
  178.         return $this;
  179.     }
  180.     public function getName(): ?string
  181.     {
  182.         return $this->name;
  183.     }
  184.     public function setName(string $name): self
  185.     {
  186.         $this->name $name;
  187.         return $this;
  188.     }
  189.     public function getSlug(): ?string
  190.     {
  191.         return $this->slug;
  192.     }
  193.     public function setSlug(string $slug): self
  194.     {
  195.         $this->slug $slug;
  196.         return $this;
  197.     }
  198.     public function getContent(): ?string
  199.     {
  200.         return $this->content;
  201.     }
  202.     public function setContent(?string $content): self
  203.     {
  204.         $this->content $content;
  205.         return $this;
  206.     }
  207.     public function getAchievement(): ?string
  208.     {
  209.         return $this->achievement;
  210.     }
  211.     public function setAchievement(?string $achievement): self
  212.     {
  213.         $this->achievement $achievement;
  214.         return $this;
  215.     }
  216.     public function getCreatedAt(): ?\DateTimeInterface
  217.     {
  218.         return $this->createdAt;
  219.     }
  220.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  221.     {
  222.         $this->createdAt $createdAt;
  223.         return $this;
  224.     }
  225.     public function getUpdatedAt(): ?\DateTimeInterface
  226.     {
  227.         return $this->updatedAt;
  228.     }
  229.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  230.     {
  231.         $this->updatedAt $updatedAt;
  232.         return $this;
  233.     }
  234.     public function getLanguage(): ?Language
  235.     {
  236.         return $this->language;
  237.     }
  238.     public function setLanguage(?Language $language): self
  239.     {
  240.         $this->language $language;
  241.         return $this;
  242.     }
  243.     /**
  244.      * @return Collection|Category[]
  245.      */
  246.     public function getCategories(): Collection
  247.     {
  248.         return $this->categories;
  249.     }
  250.     public function addCategory(Category $category): self
  251.     {
  252.         if (!$this->categories->contains($category)) {
  253.             $this->categories[] = $category;
  254.         }
  255.         return $this;
  256.     }
  257.     public function removeCategory(Category $category): self
  258.     {
  259.         if ($this->categories->contains($category)) {
  260.             $this->categories->removeElement($category);
  261.         }
  262.         return $this;
  263.     }
  264. }