added Blog entity

This commit is contained in:
2021-05-30 18:18:30 +02:00
parent aeaaae7bf5
commit 32e8e11882
5 changed files with 346 additions and 14 deletions

View File

@@ -3,6 +3,8 @@
namespace App\Entity;
use App\Repository\SectionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
@@ -32,6 +34,16 @@ class Section
*/
private $teaserImage;
/**
* @ORM\ManyToMany(targetEntity=Blog::class, mappedBy="section")
*/
private $blogs;
public function __construct()
{
$this->blogs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
@@ -72,4 +84,31 @@ class Section
return $this;
}
/**
* @return Collection|Blog[]
*/
public function getBlogs(): Collection
{
return $this->blogs;
}
public function addBlog(Blog $blog): self
{
if (!$this->blogs->contains($blog)) {
$this->blogs[] = $blog;
$blog->addSection($this);
}
return $this;
}
public function removeBlog(Blog $blog): self
{
if ($this->blogs->removeElement($blog)) {
$blog->removeSection($this);
}
return $this;
}
}