|
|
@ -4,6 +4,8 @@ namespace App\Entity;
|
|
|
|
|
|
|
|
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
|
|
use App\Repository\ProfilRepository;
|
|
|
|
use App\Repository\ProfilRepository;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
|
|
|
|
|
|
|
#[ORM\Entity(repositoryClass: ProfilRepository::class)]
|
|
|
|
#[ORM\Entity(repositoryClass: ProfilRepository::class)]
|
|
|
@ -24,6 +26,31 @@ class Profil
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
|
|
private ?string $password = null;
|
|
|
|
private ?string $password = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var Collection<int, Post>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#[ORM\OneToMany(targetEntity: Post::class, mappedBy: 'profil')]
|
|
|
|
|
|
|
|
private Collection $posts;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var Collection<int, Commentary>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#[ORM\OneToMany(targetEntity: Commentary::class, mappedBy: 'profil')]
|
|
|
|
|
|
|
|
private Collection $commentaries;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var Collection<int, self>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#[ORM\ManyToMany(targetEntity: self::class, inversedBy: 'followers')]
|
|
|
|
|
|
|
|
private Collection $followers;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->posts = new ArrayCollection();
|
|
|
|
|
|
|
|
$this->commentaries = new ArrayCollection();
|
|
|
|
|
|
|
|
$this->followers = new ArrayCollection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getId(): ?int
|
|
|
|
public function getId(): ?int
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
return $this->id;
|
|
|
@ -64,4 +91,88 @@ class Profil
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @return Collection<int, Post>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getPosts(): Collection
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->posts;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function addPost(Post $post): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!$this->posts->contains($post)) {
|
|
|
|
|
|
|
|
$this->posts->add($post);
|
|
|
|
|
|
|
|
$post->setProfil($this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function removePost(Post $post): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->posts->removeElement($post)) {
|
|
|
|
|
|
|
|
// set the owning side to null (unless already changed)
|
|
|
|
|
|
|
|
if ($post->getProfil() === $this) {
|
|
|
|
|
|
|
|
$post->setProfil(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @return Collection<int, Commentary>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getCommentaries(): Collection
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->commentaries;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function addCommentary(Commentary $commentary): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!$this->commentaries->contains($commentary)) {
|
|
|
|
|
|
|
|
$this->commentaries->add($commentary);
|
|
|
|
|
|
|
|
$commentary->setProfil($this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function removeCommentary(Commentary $commentary): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->commentaries->removeElement($commentary)) {
|
|
|
|
|
|
|
|
// set the owning side to null (unless already changed)
|
|
|
|
|
|
|
|
if ($commentary->getProfil() === $this) {
|
|
|
|
|
|
|
|
$commentary->setProfil(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @return Collection<int, self>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getFollowers(): Collection
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->followers;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function addFollower(self $follower): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!$this->followers->contains($follower)) {
|
|
|
|
|
|
|
|
$this->followers->add($follower);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function removeFollower(self $follower): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->followers->removeElement($follower);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|