<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\TMainStructureOfficesPositionsRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use Symfony\Component\Serializer\Annotation\Groups;


/**
 * @ApiResource(
 *    normalizationContext={"groups"={"t_main_structure_offices_positions:read"}, "enable_max_depth"="true", "swagger_definition_name"="Read"},
 *    denormalizationContext={"groups"={"t_main_structure_offices_positions:write"}, "swagger_definition_name"="Write"}
 * )
 * @ApiFilter(SearchFilter::class, properties={ "id": "exact", "status": "exact", "mainStructureOffice": "exact" })
 * @ApiFilter(PropertyFilter::class)
 * @ORM\Entity(repositoryClass=TMainStructureOfficesPositionsRepository::class)
 */

class TMainStructureOfficesPositions
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({ "t_main_structure_offices_positions:read", "t_main_structure_offices_positions:write", "t_staff_members:read", "t_supervisions_assignings:read", "t_witnesses_assignings:read"  })
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=TMainStructureOffices::class, inversedBy="tMainStructureOfficesPositions")
     * @Groups({ "t_main_structure_offices_positions:read", "t_main_structure_offices_positions:write", "t_staff_members:read", "t_supervisions_assignings:read" })
     */
    private $mainStructureOffice;

    /**
     * @ORM\ManyToOne(targetEntity=TStaffMembers::class, inversedBy="tMainStructureOfficesPositions")
     * @Groups({ "t_main_structure_offices_positions:read", "t_main_structure_offices_positions:write", "t_supervisions_assignings:read", "t_witnesses_assignings:read" })
     */
    private $staffMember;

    /**
     * @ORM\OneToMany(targetEntity=TMainTargetsPlannings::class, mappedBy="mainStructureOfficesPositions")
     * @Groups({ "t_main_structure_offices_positions:read", "t_main_structure_offices_positions:write" })
     */
    private $tMainTargetsPlannings;

    /**
     * @ORM\OneToMany(targetEntity=TSupervisionsAssignings::class, mappedBy="appriaserOfficePosition")
     * @Groups({ "t_main_structure_offices_positions:read", "t_main_structure_offices_positions:write", "t_staff_members:read" })
     */
    private $tSupervisionsAssignings;

    /**
     * @ORM\OneToMany(targetEntity=TWitnessesAssignings::class, mappedBy="appraiseeOfficePosition")
     */
    private $tWitnessesAssignings;

    public function __construct()
    {
        $this->tMainTargetsPlannings = new ArrayCollection();
        $this->tSupervisionsAssignings = new ArrayCollection();
        $this->tWitnessesAssignings = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getMainStructureOffice(): ?TMainStructureOffices
    {
        return $this->mainStructureOffice;
    }

    public function setMainStructureOffice(?TMainStructureOffices $mainStructureOffice): self
    {
        $this->mainStructureOffice = $mainStructureOffice;

        return $this;
    }

    public function getStaffMember(): ?TStaffMembers
    {
        return $this->staffMember;
    }

    public function setStaffMember(?TStaffMembers $staffMember): self
    {
        $this->staffMember = $staffMember;

        return $this;
    }

    /**
     * @return Collection|TMainTargetsPlannings[]
     */
    public function getTMainTargetsPlannings(): Collection
    {
        return $this->tMainTargetsPlannings;
    }

    public function addTMainTargetsPlanning(TMainTargetsPlannings $tMainTargetsPlanning): self
    {
        if (!$this->tMainTargetsPlannings->contains($tMainTargetsPlanning)) {
            $this->tMainTargetsPlannings[] = $tMainTargetsPlanning;
            $tMainTargetsPlanning->setMainStructureOfficesPositions($this);
        }

        return $this;
    }

    public function removeTMainTargetsPlanning(TMainTargetsPlannings $tMainTargetsPlanning): self
    {
        if ($this->tMainTargetsPlannings->removeElement($tMainTargetsPlanning)) {
            // set the owning side to null (unless already changed)
            if ($tMainTargetsPlanning->getMainStructureOfficesPositions() === $this) {
                $tMainTargetsPlanning->setMainStructureOfficesPositions(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TSupervisionsAssignings[]
     */
    public function getTSupervisionsAssignings(): Collection
    {
        return $this->tSupervisionsAssignings;
    }

    public function addTSupervisionsAssigning(TSupervisionsAssignings $tSupervisionsAssigning): self
    {
        if (!$this->tSupervisionsAssignings->contains($tSupervisionsAssigning)) {
            $this->tSupervisionsAssignings[] = $tSupervisionsAssigning;
            $tSupervisionsAssigning->setAppriaserOfficePosition($this);
        }

        return $this;
    }

    public function removeTSupervisionsAssigning(TSupervisionsAssignings $tSupervisionsAssigning): self
    {
        if ($this->tSupervisionsAssignings->removeElement($tSupervisionsAssigning)) {
            // set the owning side to null (unless already changed)
            if ($tSupervisionsAssigning->getAppriaserOfficePosition() === $this) {
                $tSupervisionsAssigning->setAppriaserOfficePosition(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection|TWitnessesAssignings[]
     */
    public function getTWitnessesAssignings(): Collection
    {
        return $this->tWitnessesAssignings;
    }

    public function addTWitnessesAssigning(TWitnessesAssignings $tWitnessesAssigning): self
    {
        if (!$this->tWitnessesAssignings->contains($tWitnessesAssigning)) {
            $this->tWitnessesAssignings[] = $tWitnessesAssigning;
            $tWitnessesAssigning->setAppraiseeOfficePosition($this);
        }

        return $this;
    }

    public function removeTWitnessesAssigning(TWitnessesAssignings $tWitnessesAssigning): self
    {
        if ($this->tWitnessesAssignings->removeElement($tWitnessesAssigning)) {
            // set the owning side to null (unless already changed)
            if ($tWitnessesAssigning->getAppraiseeOfficePosition() === $this) {
                $tWitnessesAssigning->setAppraiseeOfficePosition(null);
            }
        }

        return $this;
    }
}
