<?php
namespace App\Entity\Produit\Service;
use App\Entity\Users\User\User;
use App\Repository\Produit\Service\ArticleRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="`article`")
* @ORM\Entity(repositoryClass=ArticleRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class Article
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="text")
*/
private $content;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=Typearticle::class)
* @ORM\JoinColumn(nullable=false)
*/
private $typearticle;
/**
* @ORM\Column(type="integer")
*/
private $rang;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $user;
/**
* @ORM\OneToOne(targetEntity=Imgarticle::class, cascade={"persist", "remove"})
*/
private $imgarticle;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $keywords;
public function __construct()
{
$this->createdAt = new \Datetime();
$this->rang = 0;
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getTypearticle(): ?Typearticle
{
return $this->typearticle;
}
public function setTypearticle(?Typearticle $typearticle): self
{
$this->typearticle = $typearticle;
return $this;
}
/**
* @ORM\PrePersist()
*/
public function preUpload()
{
$this->typearticle->setArticleNumber($this->typearticle->getArticleNumber() + 1);
}
/**
* @ORM\PostRemove()
*/
public function postDelete()
{
$this->typearticle->setArticleNumber($this->typearticle->getArticleNumber() - 1);
}
public function getRang(): ?int
{
return $this->rang;
}
public function setRang(int $rang): self
{
$this->rang = $rang;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getImgarticle(): ?Imgarticle
{
return $this->imgarticle;
}
public function setImgarticle(?Imgarticle $imgarticle): self
{
$this->imgarticle = $imgarticle;
return $this;
}
public function getKeywords(): ?string
{
return $this->keywords;
}
public function setKeywords(?string $keywords): self
{
$this->keywords = $keywords;
return $this;
}
}