nineskeletor/src/Entity/Pin.php

162 lines
2.9 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;
/**
* Pin.
*
* @ORM\Table(name="pin")
* @ORM\Entity(repositoryClass="App\Repository\PinRepository")
* @ORM\HasLifecycleCallbacks
*/
class Pin
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $name;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $subname;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $image;
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $submitdate;
/**
* @ORM\ManyToMany(targetEntity="Child", mappedBy="pins")
*/
protected $childs;
public function __construct()
{
$this->childs = new ArrayCollection();
}
/**
* @ORM\PrePersist
*/
public function onPrePersist()
{
$this->submitdate = new \DateTime('now');
}
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSubname(): ?string
{
return $this->subname;
}
public function setSubname(?string $subname): self
{
$this->subname = $subname;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getSubmitdate(): ?\DateTimeInterface
{
return $this->submitdate;
}
public function setSubmitdate(\DateTimeInterface $submitdate): self
{
$this->submitdate = $submitdate;
return $this;
}
/**
* @return Collection|Child[]
*/
public function getChilds(): Collection
{
return $this->childs;
}
public function addChild(Child $child): self
{
if (!$this->childs->contains($child)) {
$this->childs[] = $child;
$child->addPin($this);
}
return $this;
}
public function removeChild(Child $child): self
{
if ($this->childs->contains($child)) {
$this->childs->removeElement($child);
$child->removePin($this);
}
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
}