src/Entity/Testimony.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TestimonyRepository;
  4. use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
  5. use DateTime;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass=TestimonyRepository::class)
  12.  */
  13. class Testimony
  14. {
  15.         
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="float")
  24.      * @Assert\LessThan(
  25.      *      value=5.0000000001,
  26.      *      message="La note doit être inférieur à 5"
  27.      * )
  28.      * @Assert\GreaterThan(
  29.      *      value=0,
  30.      *      message="La note doit être supérieur à 0"
  31.      * )
  32.      */
  33.     private $rating;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      * @CrudField(index=true, label="Prénom")
  37.      */
  38.     private $firstname;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      * @CrudField(label="Nom")
  42.      */
  43.     private $name;
  44.     /**
  45.      * @ORM\Column(type="text")
  46.      * @CrudField(label="Témoignage")
  47.      */
  48.     private $testimony;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      * @CrudField(label="Fonction", index=true)
  52.      */
  53.     private $role;
  54.     /**
  55.      * @ORM\Column(type="boolean", nullable=true)
  56.      * @CrudField(index=true, label="Publié")
  57.      */
  58.     private $published;
  59.     /**
  60.      * @ORM\ManyToMany(targetEntity=LandingPage::class, mappedBy="testimonies")
  61.      */
  62.     private $landingPages;
  63.     /**
  64.      * @ORM\ManyToOne(targetEntity=Homepage::class, inversedBy="testimonies")
  65.      */
  66.     private $homepage;
  67.     /**
  68.      * @ORM\Column(type="date")
  69.      * @CrudField(label="Date d'ajout")
  70.      */
  71.     private $date;
  72.     /**
  73.      * @ORM\Column(type="string", length=255)
  74.      * @CrudField(label="Email")
  75.      */
  76.     private $email;
  77.     public function __construct()
  78.     {
  79.         $this->landingPages = new ArrayCollection();
  80.         $this->date = new DateTime();
  81.         $this->published false;
  82.     }
  83.     public function __toString(): string
  84.     {
  85.         if ($this->getRole() != null) {
  86.             return $this->getName() . ' ' $this->getFirstname() . ' ' $this->getRole();
  87.         } else {
  88.             return $this->getName() . ' ' $this->getFirstname();
  89.         }
  90.     }
  91.     public function getId(): ?int
  92.     {
  93.         return $this->id;
  94.     }
  95.     public function getRating(): ?float
  96.     {
  97.         return $this->rating;
  98.     }
  99.     public function setRating(float $rating): self
  100.     {
  101.         $this->rating $rating;
  102.         return $this;
  103.     }
  104.     public function getFirstname(): ?string
  105.     {
  106.         return $this->firstname;
  107.     }
  108.     public function setFirstname(string $firstname): self
  109.     {
  110.         $this->firstname $firstname;
  111.         return $this;
  112.     }
  113.     public function getName(): ?string
  114.     {
  115.         return $this->name;
  116.     }
  117.     public function setName(string $name): self
  118.     {
  119.         $this->name $name;
  120.         return $this;
  121.     }
  122.     public function getTestimony(): ?string
  123.     {
  124.         return $this->testimony;
  125.     }
  126.     public function setTestimony(string $testimony): self
  127.     {
  128.         $this->testimony $testimony;
  129.         return $this;
  130.     }
  131.     public function getRole(): ?string
  132.     {
  133.         return $this->role;
  134.     }
  135.     public function setRole(?string $role): self
  136.     {
  137.         $this->role $role;
  138.         return $this;
  139.     }
  140.     public function isPublished(): ?bool
  141.     {
  142.         return $this->published;
  143.     }
  144.     public function setPublished(?bool $published): self
  145.     {
  146.         $this->published $published;
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection<int, LandingPage>
  151.      */
  152.     public function getLandingPages(): Collection
  153.     {
  154.         return $this->landingPages;
  155.     }
  156.     public function addLandingPage(LandingPage $landingPage): self
  157.     {
  158.         if (!$this->landingPages->contains($landingPage)) {
  159.             $this->landingPages[] = $landingPage;
  160.             $landingPage->addTestimony($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeLandingPage(LandingPage $landingPage): self
  165.     {
  166.         if ($this->landingPages->removeElement($landingPage)) {
  167.             $landingPage->removeTestimony($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function getHomepage(): ?Homepage
  172.     {
  173.         return $this->homepage;
  174.     }
  175.     public function setHomepage(?Homepage $homepage): self
  176.     {
  177.         $this->homepage $homepage;
  178.         return $this;
  179.     }
  180.     public function getDate(): ?\DateTimeInterface
  181.     {
  182.         return $this->date;
  183.     }
  184.     public function setDate(\DateTimeInterface $date): self
  185.     {
  186.         $this->date $date;
  187.         return $this;
  188.     }
  189.     public function getEmail(): ?string
  190.     {
  191.         return $this->email;
  192.     }
  193.     public function setEmail(string $email): self
  194.     {
  195.         $this->email $email;
  196.         return $this;
  197.     }
  198. }