src/Entity/Produit/Service/Article.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Produit\Service;
  3. use App\Entity\Users\User\User;
  4. use App\Repository\Produit\Service\ArticleRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Table(name="`article`")
  8.  * @ORM\Entity(repositoryClass=ArticleRepository::class)
  9.  * @ORM\HasLifecycleCallbacks
  10.  */
  11. class Article
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $title;
  23.     /**
  24.      * @ORM\Column(type="text")
  25.      */
  26.     private $content;
  27.     /**
  28.      * @ORM\Column(type="datetime")
  29.      */
  30.     private $createdAt;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=Typearticle::class)
  33.      * @ORM\JoinColumn(nullable=false)
  34.      */
  35.     private $typearticle;
  36.     /**
  37.      * @ORM\Column(type="integer")
  38.      */
  39.     private $rang;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity=User::class)
  42.      */
  43.     private $user;
  44.     /**
  45.      * @ORM\OneToOne(targetEntity=Imgarticle::class, cascade={"persist", "remove"})
  46.      */
  47.     private $imgarticle;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $keywords;
  52.     public function __construct()
  53.     {
  54.         $this->createdAt = new \Datetime();
  55.         $this->rang 0;
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getTitle(): ?string
  62.     {
  63.         return $this->title;
  64.     }
  65.     public function setTitle(string $title): self
  66.     {
  67.         $this->title $title;
  68.         return $this;
  69.     }
  70.     public function getContent(): ?string
  71.     {
  72.         return $this->content;
  73.     }
  74.     public function setContent(string $content): self
  75.     {
  76.         $this->content $content;
  77.         return $this;
  78.     }
  79.     public function getCreatedAt(): ?\DateTimeInterface
  80.     {
  81.         return $this->createdAt;
  82.     }
  83.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  84.     {
  85.         $this->createdAt $createdAt;
  86.         return $this;
  87.     }
  88.     public function getTypearticle(): ?Typearticle
  89.     {
  90.         return $this->typearticle;
  91.     }
  92.     public function setTypearticle(?Typearticle $typearticle): self
  93.     {
  94.         $this->typearticle $typearticle;
  95.         return $this;
  96.     }
  97.     /**
  98.     * @ORM\PrePersist()
  99.     */
  100.     public function preUpload()
  101.              {
  102.                  $this->typearticle->setArticleNumber($this->typearticle->getArticleNumber() + 1);
  103.              }
  104.     /**
  105.     * @ORM\PostRemove()
  106.     */
  107.     public function postDelete()
  108.     {
  109.         $this->typearticle->setArticleNumber($this->typearticle->getArticleNumber() - 1);
  110.     }
  111.     public function getRang(): ?int
  112.     {
  113.         return $this->rang;
  114.     }
  115.     public function setRang(int $rang): self
  116.     {
  117.         $this->rang $rang;
  118.         return $this;
  119.     }
  120.     public function getUser(): ?User
  121.     {
  122.         return $this->user;
  123.     }
  124.     public function setUser(?User $user): self
  125.     {
  126.         $this->user $user;
  127.         return $this;
  128.     }
  129.     public function getImgarticle(): ?Imgarticle
  130.     {
  131.         return $this->imgarticle;
  132.     }
  133.     public function setImgarticle(?Imgarticle $imgarticle): self
  134.     {
  135.         $this->imgarticle $imgarticle;
  136.         return $this;
  137.     }
  138.     public function getKeywords(): ?string
  139.     {
  140.         return $this->keywords;
  141.     }
  142.     public function setKeywords(?string $keywords): self
  143.     {
  144.         $this->keywords $keywords;
  145.         return $this;
  146.     }
  147. }