<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\AvisUtilisateurRepository")
* @ORM\Table(name="avis_utilisateur")
* @ORM\HasLifecycleCallbacks()
*/
class AvisUtilisateur
{
/**
* @ORM\ManyToOne(targetEntity="\App\Entity\Boutique")
*/
private $boutique;
/**
* @ORM\ManyToOne(targetEntity="\App\Entity\AppUser")
*/
private $user;
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var datetime|null
*
* @ORM\Column(name="la_date", type="datetime", nullable=true)
*/
private $laDate;
/**
* @var integer|null
*
* @ORM\Column(name="valeur_avis", type="integer", nullable=true)
*/
private $valeurAvis;
/**
* @var integer|null
*
* @ORM\Column(name="avis_utile", type="integer", nullable=true)
*/
private $avisUtile;
/**
* @var integer|null
*
* @ORM\Column(name="avis_inutile", type="integer", nullable=true)
*/
private $avisInutile;
/**
* @var integer|null
*
* @ORM\Column(name="signaler_avis", type="integer", nullable=true)
*/
private $signalerAvis;
/**
* @var string|null
*
* @ORM\Column(name="contenu", type="text", nullable=true)
*/
private $contenu;
/**
* @var string|null
*
* @ORM\Column(name="reponse_avis", type="text", nullable=true)
*/
private $reponseAvis;
public function __construct()
{
$this->laDate = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getContenu(): ?string
{
return $this->contenu;
}
public function setContenu(?string $contenu): self
{
$this->contenu = $contenu;
return $this;
}
public function getBoutique(): ?Boutique
{
return $this->boutique;
}
public function setBoutique(?Boutique $boutique): self
{
$this->boutique = $boutique;
return $this;
}
public function getValeurAvis(): ?int
{
return $this->valeurAvis;
}
public function setValeurAvis(?int $valeurAvis): self
{
$this->valeurAvis = $valeurAvis;
return $this;
}
/**
@ORM\PrePersist
*/
public function augmenterNombreElementParent()
{
if($this->getBoutique() != null){
$nb = $this->getBoutique()->getNombreAvis();
$this->getBoutique()->setNombreAvis($nb+1);
}
if($this->getUser() != null){
$nb = $this->getUser()->getNombreAvis();
$this->getUser()->setNombreAvis($nb+1);
}
}
/**
@ORM\PreRemove
*/
public function diminuerNombreElementParent()
{
if($this->getBoutique() != null){
$nb = $this->getBoutique()->getNombreAvis();
$this->getBoutique()->setNombreAvis($nb-1);
}
if($this->getUser() != null){
$nb = $this->getUser()->getNombreAvis();
$this->getUser()->setNombreAvis($nb-1);
}
}
public function getUser(): ?AppUser
{
return $this->user;
}
public function setUser(?AppUser $user): self
{
$this->user = $user;
return $this;
}
public function getLaDate(): ?\DateTimeInterface
{
return $this->laDate;
}
public function setLaDate(?\DateTimeInterface $laDate): self
{
$this->laDate = $laDate;
return $this;
}
public function getReponseAvis(): ?string
{
return $this->reponseAvis;
}
public function setReponseAvis(?string $reponseAvis): self
{
$this->reponseAvis = $reponseAvis;
return $this;
}
public function getAvisUtile(): ?int
{
return $this->avisUtile;
}
public function setAvisUtile(?int $avisUtile): self
{
$this->avisUtile = $avisUtile;
return $this;
}
public function getAvisInutile(): ?int
{
return $this->avisInutile;
}
public function setAvisInutile(?int $avisInutile): self
{
$this->avisInutile = $avisInutile;
return $this;
}
public function getSignalerAvis(): ?int
{
return $this->signalerAvis;
}
public function setSignalerAvis(?int $signalerAvis): self
{
$this->signalerAvis = $signalerAvis;
return $this;
}
}