nineskeletor/src/Entity/Blog.php

202 lines
4.1 KiB
PHP

<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* Blog.
*
* @ORM\Table(name="Blog")
* @ORM\Entity(repositoryClass="App\Repository\BlogRepository")
* @ORM\HasLifecycleCallbacks
*/
class Blog
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $name;
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $submitdate;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $externalcode;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $externalid;
/**
* @ORM\ManyToOne(targetEntity="Blogtype", inversedBy="blogs")
*/
private $blogtype;
/**
* @ORM\OneToMany(targetEntity="Child", mappedBy="blog", cascade={"persist"}, orphanRemoval=true)
* @ORM\OrderBy({"roworder" = "ASC"})
*/
private $childs;
/**
* @ORM\OneToMany(targetEntity="Menuchild", mappedBy="blog", cascade={"persist"}, orphanRemoval=true)
*/
private $menuchilds;
public function __construct()
{
$this->childs = new ArrayCollection();
$this->menuchilds = new ArrayCollection();
}
/**
* @ORM\PrePersist
*/
public function onPrePersist()
{
$this->submitdate = new \DateTime('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSubmitdate(): ?\DateTimeInterface
{
return $this->submitdate;
}
public function setSubmitdate(\DateTimeInterface $submitdate): self
{
$this->submitdate = $submitdate;
return $this;
}
public function getExternalcode(): ?string
{
return $this->externalcode;
}
public function setExternalcode(?string $externalcode): self
{
$this->externalcode = $externalcode;
return $this;
}
public function getExternalid(): ?string
{
return $this->externalid;
}
public function setExternalid(?string $externalid): self
{
$this->externalid = $externalid;
return $this;
}
public function getBlogtype(): ?Blogtype
{
return $this->blogtype;
}
public function setBlogtype(?Blogtype $blogtype): self
{
$this->blogtype = $blogtype;
return $this;
}
/**
* @return Collection<int, Child>
*/
public function getChilds(): Collection
{
return $this->childs;
}
public function addChild(Child $child): self
{
if (!$this->childs->contains($child)) {
$this->childs->add($child);
$child->setBlog($this);
}
return $this;
}
public function removeChild(Child $child): self
{
if ($this->childs->removeElement($child)) {
// set the owning side to null (unless already changed)
if ($child->getBlog() === $this) {
$child->setBlog(null);
}
}
return $this;
}
/**
* @return Collection<int, Menuchild>
*/
public function getMenuchilds(): Collection
{
return $this->menuchilds;
}
public function addMenuchild(Menuchild $menuchild): self
{
if (!$this->menuchilds->contains($menuchild)) {
$this->menuchilds->add($menuchild);
$menuchild->setBlog($this);
}
return $this;
}
public function removeMenuchild(Menuchild $menuchild): self
{
if ($this->menuchilds->removeElement($menuchild)) {
// set the owning side to null (unless already changed)
if ($menuchild->getBlog() === $this) {
$menuchild->setBlog(null);
}
}
return $this;
}
}