<?php
namespace App\Entity\Law;
use App\Entity\Law\Law;
use App\Repository\Law\SectionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SectionRepository::class)
*/
class Section
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $slug;
/**
* @ORM\OneToMany(targetEntity=Law::class, mappedBy="section")
*/
private $laws;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nameEng;
public function __construct()
{
$this->laws = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
}
public function __toString(): string
{
return $this->name;
}
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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection|Law[]
*/
public function getLaws(): Collection
{
return $this->laws;
}
public function addLaw(Law $law): self
{
if (!$this->laws->contains($law)) {
$this->laws[] = $law;
$law->setSection($this);
}
return $this;
}
public function removeLaw(Law $law): self
{
if ($this->laws->removeElement($law)) {
// set the owning side to null (unless already changed)
if ($law->getSection() === $this) {
$law->setSection(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getNameEng(): ?string
{
return $this->nameEng;
}
public function setNameEng(?string $nameEng): self
{
$this->nameEng = $nameEng;
return $this;
}
}