<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ApiResource(
* iri="http://schema.org/Thing",
* collectionOperations={
* "get"={
* "access_control"="is_granted('ROLE_USER')",
* "method"="GET",
* "normalization_context"={
* "groups"={"output"}
* },
* "denormalization_context"={
* "groups"={"input"}
* }
* },
* "post"={
* "access_control"="is_granted('ROLE_USER')",
* "method"="POST",
* "normalization_context"={
* "groups"={"output"}
* },
* "denormalization_context"={
* "groups"={"input"}
* }
* }
* },
* itemOperations={
* "delete"={
* "access_control"="is_granted('IS_OWNER', object) or is_granted('ROLE_ADMIN') or is_granted('ROLE_SUPER_ADMIN')",
* "normalization_context"={
* "groups"={"output"}
* },
* "denormalization_context"={
* "groups"={"input"}
* }
* },
* "get"={
* "access_control"="is_granted('IS_OWNER', object) or is_granted('ROLE_ADMIN') or is_granted('ROLE_SUPER_ADMIN')",
* "method"="GET",
* "normalization_context"={
* "groups"={"output"}
* },
* "denormalization_context"={
* "groups"={"input"}
* }
* },
* "put"={
* "access_control"="is_granted('IS_OWNER', object) or is_granted('ROLE_ADMIN') or is_granted('ROLE_SUPER_ADMIN')",
* "method"="PUT",
* "normalization_context"={
* "groups"={"output"}
* },
* "denormalization_context"={
* "groups"={"input"}
* }
* }
* },
* attributes={
* "filters"={
* "child.search_filter",
* "child.order_filter",
* "child.date_filter",
* },
* "normalization_context"={
* "groups"={""}
* },
* "denormalization_context"={
* "groups"={""}
* },
* "pagination_items_per_page"=10,
* "pagination_client_items_per_page"=true
* }
* )
*
* The most generic type of item.
*
* @see http://schema.org/Thing Documentation on Schema.org
*/
class Child extends AbstractTimestamp
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
* @Groups({"output"})
*
* @var int|null
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="children")
*
* @var User|null
*/
protected $createdBy;
/**
* @ORM\Column(type="datetime")
* @Groups({"output", "input"})
*
* @var \DateTimeInterface|null
*
*/
protected $birthdate;
/**
* @ORM\Column(type="string", length=180, nullable=false)
* @Groups({"output", "input"})
*
* #[ApiFilter(SearchFilter::class, strategy: 'partial')]
*
* @var string|null
*/
protected $firstName;
/**
* @ORM\Column(type="string", length=180, nullable=true)
* @Groups({"output", "input"})
*
* @var string|null
*/
protected $middleName;
/**
* @ORM\Column(type="string", length=180, nullable=false)
* @Groups({"output", "input"})
*
* @var string|null
*/
protected $lastName;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Lookup")
* @Groups({"output", "input"})
*
* @var Lookup|null
*/
protected $stateOfResidence;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Lookup")
* @Groups({"output", "input"})
*
* @var Lookup|null
*/
protected $suffix;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Referral", mappedBy="child")
* @ORM\JoinColumn(referencedColumnName="id")
*
* @var Collection<Referral>
*
* @Assert\NotNull
*/
protected $referrals;
public function __construct()
{
$this->referrals = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setBirthdate(?\DateTimeInterface $birthdate): self
{
$this->birthdate = $birthdate;
return $this;
}
public function getBirthdate(): ?\DateTimeInterface
{
return $this->birthdate;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setMiddleName(?string $middleName): self
{
$this->middleName = $middleName;
return $this;
}
public function getMiddleName(): ?string
{
return $this->middleName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setStateOfResidence(?Lookup $stateOfResidence): self
{
$this->stateOfResidence = $stateOfResidence;
return $this;
}
public function getStateOfResidence(): ?Lookup
{
return $this->stateOfResidence;
}
public function setSuffix(?Lookup $suffix): self
{
$this->suffix = $suffix;
return $this;
}
public function getSuffix(): ?Lookup
{
return $this->suffix;
}
public function addReferral(Referral $referral): self
{
$this->referrals[] = $referral;
return $this;
}
public function removeReferral(Referral $referral): self
{
$this->referrals->removeElement($referral);
return $this;
}
public function getReferrals(): Collection
{
return $this->referrals;
}
}