src/Entity/AvisUtilisateur.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\AvisUtilisateurRepository")
  8.  * @ORM\Table(name="avis_utilisateur")
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class AvisUtilisateur
  12. {
  13.     /**
  14.      * @ORM\ManyToOne(targetEntity="\App\Entity\Boutique")
  15.      */
  16.     private $boutique;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity="\App\Entity\AppUser")
  19.      */
  20.     private $user;
  21.     
  22.     /**
  23.      * @var int
  24.      *
  25.      * @ORM\Column(name="id", type="integer", nullable=false)
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="IDENTITY")
  28.      */
  29.     private $id;
  30.     
  31.     /**
  32.      * @var datetime|null
  33.      *
  34.      * @ORM\Column(name="la_date", type="datetime", nullable=true)
  35.      */
  36.     private $laDate;
  37.     
  38.     /**
  39.      * @var integer|null
  40.      *
  41.      * @ORM\Column(name="valeur_avis", type="integer", nullable=true)
  42.      */
  43.     private $valeurAvis;
  44.     
  45.     /**
  46.      * @var integer|null
  47.      *
  48.      * @ORM\Column(name="avis_utile", type="integer", nullable=true)
  49.      */
  50.     private $avisUtile;
  51.     
  52.     /**
  53.      * @var integer|null
  54.      *
  55.      * @ORM\Column(name="avis_inutile", type="integer", nullable=true)
  56.      */
  57.     private $avisInutile;
  58.     
  59.     /**
  60.      * @var integer|null
  61.      *
  62.      * @ORM\Column(name="signaler_avis", type="integer", nullable=true)
  63.      */
  64.     private $signalerAvis;
  65.     
  66.     /**
  67.      * @var string|null
  68.      *
  69.      * @ORM\Column(name="contenu", type="text", nullable=true)
  70.      */
  71.     private $contenu;
  72.     
  73.     /**
  74.      * @var string|null
  75.      *
  76.      * @ORM\Column(name="reponse_avis", type="text", nullable=true)
  77.      */
  78.     private $reponseAvis;
  79.     public function __construct()
  80.     {
  81.         $this->laDate = new \DateTime();
  82.     }
  83.    
  84.     public function getId(): ?int
  85.     {
  86.         return $this->id;
  87.     }
  88.     
  89.     public function getContenu(): ?string
  90.                                                     {
  91.                                                         return $this->contenu;
  92.                                                     }
  93.     public function setContenu(?string $contenu): self
  94.     {
  95.         $this->contenu $contenu;
  96.         return $this;
  97.     }
  98.     public function getBoutique(): ?Boutique
  99.     {
  100.         return $this->boutique;
  101.     }
  102.     public function setBoutique(?Boutique $boutique): self
  103.     {
  104.         $this->boutique $boutique;
  105.         return $this;
  106.     }
  107.     public function getValeurAvis(): ?int
  108.     {
  109.         return $this->valeurAvis;
  110.     }
  111.     public function setValeurAvis(?int $valeurAvis): self
  112.     {
  113.         $this->valeurAvis $valeurAvis;
  114.         return $this;
  115.     }
  116.     /**
  117.      @ORM\PrePersist
  118.     */
  119.     
  120.     public function augmenterNombreElementParent()
  121.     {
  122.         if($this->getBoutique() != null){
  123.             $nb $this->getBoutique()->getNombreAvis();
  124.             $this->getBoutique()->setNombreAvis($nb+1);
  125.         }
  126.         if($this->getUser() != null){
  127.             $nb $this->getUser()->getNombreAvis();
  128.             $this->getUser()->setNombreAvis($nb+1);
  129.         }
  130.     }
  131.     
  132.     /**
  133.      @ORM\PreRemove
  134.     */
  135.     
  136.     public function diminuerNombreElementParent()
  137.     {
  138.         if($this->getBoutique() != null){
  139.             $nb $this->getBoutique()->getNombreAvis();
  140.             $this->getBoutique()->setNombreAvis($nb-1);
  141.         }
  142.         
  143.         if($this->getUser() != null){
  144.             $nb $this->getUser()->getNombreAvis();
  145.             $this->getUser()->setNombreAvis($nb-1);
  146.         }
  147.     }
  148.     public function getUser(): ?AppUser
  149.     {
  150.         return $this->user;
  151.     }
  152.     public function setUser(?AppUser $user): self
  153.     {
  154.         $this->user $user;
  155.         return $this;
  156.     }
  157.     public function getLaDate(): ?\DateTimeInterface
  158.     {
  159.         return $this->laDate;
  160.     }
  161.     public function setLaDate(?\DateTimeInterface $laDate): self
  162.     {
  163.         $this->laDate $laDate;
  164.         return $this;
  165.     }
  166.     public function getReponseAvis(): ?string
  167.     {
  168.         return $this->reponseAvis;
  169.     }
  170.     public function setReponseAvis(?string $reponseAvis): self
  171.     {
  172.         $this->reponseAvis $reponseAvis;
  173.         return $this;
  174.     }
  175.     public function getAvisUtile(): ?int
  176.     {
  177.         return $this->avisUtile;
  178.     }
  179.     public function setAvisUtile(?int $avisUtile): self
  180.     {
  181.         $this->avisUtile $avisUtile;
  182.         return $this;
  183.     }
  184.     public function getAvisInutile(): ?int
  185.     {
  186.         return $this->avisInutile;
  187.     }
  188.     public function setAvisInutile(?int $avisInutile): self
  189.     {
  190.         $this->avisInutile $avisInutile;
  191.         return $this;
  192.     }
  193.     public function getSignalerAvis(): ?int
  194.     {
  195.         return $this->signalerAvis;
  196.     }
  197.     public function setSignalerAvis(?int $signalerAvis): self
  198.     {
  199.         $this->signalerAvis $signalerAvis;
  200.         return $this;
  201.     }
  202.     
  203. }