src/Entity/FamilyMember.php line 22
<?php
namespace App\Entity;
use Symfony\Component\Uid\Ulid;
use App\Entity\enums\FamilySituation;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\FamilyMemberRepository;
use Doctrine\Common\Collections\Collection;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: FamilyMemberRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[ORM\HasLifecycleCallbacks]
#[ApiResource(
attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
)]
class FamilyMember
{
use Timestamps;
#[ORM\Id]
#[ORM\Column(type: 'ulid', unique: true)]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
#[Groups(['read:familymember:basic'])]
private ?Ulid $id = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:familymember:basic'])]
private $type;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:familymember:basic'])]
private $first_name;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:familymember:basic'])]
private $last_name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:familymember:basic'])]
private $email;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:familymember:basic'])]
private $phone;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:familymember:basic'])]
private $mobile;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:familymember:basic'])]
private $job;
#[ORM\Column(type: 'boolean')]
private $legal_guardian;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:familymember:basic'])]
private $photo;
#[ORM\OneToMany(mappedBy: 'familyMember', targetEntity: Cardid::class, orphanRemoval: true, cascade: ['persist', 'remove'])]
private $identity;
#[ORM\OneToOne(targetEntity: Location::class, cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: true)]
private $address;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'familyMembers')]
private $owner;
#[ORM\ManyToMany(targetEntity: Child::class, mappedBy: 'family')]
private $children;
#[ORM\OneToMany(mappedBy: 'payed_by', targetEntity: Payment::class)]
private $payments;
#[ORM\ManyToOne(targetEntity: Season::class, inversedBy: 'familyMembers')]
#[ORM\JoinColumn(nullable: false)]
private $season;
#[ORM\Column(type: 'string', length: 255, enumType: FamilySituation::class)]
private $family_situation;
public function __construct()
{
$this->identity = new ArrayCollection();
$this->legal_guardian = false;
$this->children = new ArrayCollection();
$this->payments = new ArrayCollection();
$this->family_situation = FamilySituation::MARIED;
}
public function __toString()
{
return $this->first_name . " " . $this->last_name;
;
}
public function getId(): ?Ulid
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getFirstName(): ?string
{
return $this->first_name;
}
public function setFirstName(string $first_name): self
{
$this->first_name = $first_name;
return $this;
}
public function getLastName(): ?string
{
return $this->last_name;
}
public function setLastName(string $last_name): self
{
$this->last_name = $last_name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getMobile(): ?string
{
return $this->mobile;
}
public function setMobile(?string $mobile): self
{
$this->mobile = $mobile;
return $this;
}
public function getJob(): ?string
{
return $this->job;
}
public function setJob(?string $job): self
{
$this->job = $job;
return $this;
}
public function isLegalGuardian(): ?bool
{
return $this->legal_guardian;
}
public function setLegalGuardian(bool $legal_guardian): self
{
$this->legal_guardian = $legal_guardian;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
/**
* @return Collection<int, Cardid>
*/
public function getIdentity(): Collection
{
return $this->identity;
}
public function addIdentity(Cardid $identity): self
{
if (!$this->identity->contains($identity)) {
$this->identity[] = $identity;
$identity->setFamilyMember($this);
}
return $this;
}
public function removeIdentity(Cardid $identity): self
{
if ($this->identity->removeElement($identity)) {
// set the owning side to null (unless already changed)
if ($identity->getFamilyMember() === $this) {
$identity->setFamilyMember(null);
}
}
return $this;
}
public function getAddress(): ?Location
{
return $this->address;
}
public function setAddress(?Location $address): self
{
$this->address = $address;
return $this;
}
public function getOwner(): ?Company
{
return $this->owner;
}
public function setOwner(?Company $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* @return Collection<int, Child>
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(Child $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->addFamily($this);
}
return $this;
}
public function removeChild(Child $child): self
{
if ($this->children->removeElement($child)) {
$child->removeFamily($this);
}
return $this;
}
/**
* @return Collection<int, Payment>
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments[] = $payment;
$payment->setPayedBy($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getPayedBy() === $this) {
$payment->setPayedBy(null);
}
}
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): self
{
$this->season = $season;
return $this;
}
public function getFamilySituation(): ?FamilySituation
{
return $this->family_situation;
}
public function setFamilySituation(?FamilySituation $family_situation): self
{
$this->family_situation = $family_situation;
return $this;
}
}