src/Entity/Qualification.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QualificationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\MaxDepth;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ORM\Entity(repositoryClass=QualificationRepository::class)
  12.  * @UniqueEntity(
  13.  *       fields={"name"},
  14.  *       message="Qualifcation with name (%s) is already registered"
  15.  *  )
  16.  */
  17. class Qualification
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      * @Groups({
  24.      *     "qualifications.base",
  25.      *     "project.qualifications",
  26.      *     "partner.joined.projects.depended.qualifications",
  27.      *     "stakeholder.selected.core.project.manage",
  28.      *     "worker.manage.base",
  29.      *     "worker.manage.selected.worker.in.project",
  30.      *     "worker.manage.joined.projects",
  31.      *     "selected.partner.project.for.worker",
  32.      *
  33.      *     "qualification@core"
  34.      *
  35.      * })
  36.      */
  37.     private $id;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, unique=true)
  40.      * @Groups({
  41.      *     "qualifications.base",
  42.      *     "project.qualifications",
  43.      *     "partner.joined.projects.depended.qualifications",
  44.      *     "stakeholder.selected.core.project.manage",
  45.      *     "worker.manage.base",
  46.      *     "worker.manage.selected.worker.in.project",
  47.      *     "worker.manage.joined.projects",
  48.      *     "selected.partner.project.for.worker",
  49.      *
  50.      *     "qualification@core"
  51.      * })
  52.      */
  53.     private $name;
  54.     /**
  55.      * @ORM\ManyToMany(targetEntity=Worker::class, mappedBy="qualifications")
  56.      */
  57.     private $workers;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true )
  60.      * @Groups({
  61.      *     "qualifications.base",
  62.      *     "project.qualifications",
  63.      *     "partner.joined.projects.depended.qualifications",
  64.      *     "stakeholder.selected.core.project.manage",
  65.      *     "worker.manage.selected.worker.in.project",
  66.      *     "worker.manage.joined.projects",
  67.      *
  68.      *     "qualification@core"
  69.      * })
  70.      */
  71.     private $color;
  72.     /**
  73.      * @ORM\ManyToMany(targetEntity=ProjectStakeholders::class, mappedBy="dependent_qualifications" )
  74.      */
  75.     private $project_stakeholders;
  76.     /**
  77.      * @ORM\ManyToMany(targetEntity=WorkerInProject::class, mappedBy="assigned_qualifications")
  78.      */
  79.     private $workerInProjects;
  80.     /**
  81.      * @ORM\ManyToMany(targetEntity=Projects::class, mappedBy="dependent_qualifications")
  82.      */
  83.     private $projects;
  84. //    /**
  85. //     * @ORM\OneToMany(targetEntity=AccessAddTimesheetTime::class, mappedBy="qualification")
  86. //     */
  87.     # private $accessAddTimesheetTimes;
  88.     public function __construct()
  89.     {
  90.         $this->workers = new ArrayCollection();
  91.         $this->project_stakeholders = new ArrayCollection();
  92.         $this->workerInProjects = new ArrayCollection();
  93.         $this->projects = new ArrayCollection();
  94.         # $this->accessAddTimesheetTimes = new ArrayCollection();
  95.     }
  96.     public function getId(): ?int
  97.     {
  98.         return $this->id;
  99.     }
  100.     public function getName(): ?string
  101.     {
  102.         return $this->name;
  103.     }
  104.     public function setName(string $name): self
  105.     {
  106.         $this->name $name;
  107.         return $this;
  108.     }
  109. //    /**
  110. //     * @return Collection<int, Worker>
  111. //     */
  112. //    public function getWorkers(): ?Collection
  113. //    {
  114. //        return $this->workers;
  115. //    }
  116.     public function addWorker(Worker $worker): self
  117.     {
  118.         if (!$this->workers->contains($worker)) {
  119.             $this->workers[] = $worker;
  120.             $worker->addQualification($this);
  121.         }
  122.         return $this;
  123.     }
  124.     public function removeWorker(Worker $worker): self
  125.     {
  126.         if ($this->workers->removeElement($worker)) {
  127.             $worker->removeQualification($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function getColor(): ?string
  132.     {
  133.         return $this->color;
  134.     }
  135.     public function setColor(?string $color): self
  136.     {
  137.         $this->color $color;
  138.         return $this;
  139.     }
  140. //    /**
  141. //     * @return Collection<int, ProjectStakeholders>
  142. //     */
  143. //    public function getProjectStakeholders(): Collection
  144. //    {
  145. //
  146. ////        return $this->projectStakeholders->map(function(/**@var $projectStakeholder ProjectStakeholders*/$projectStakeholder){
  147. ////            return [
  148. ////                'id' => $projectStakeholder->getId(),
  149. ////                $projectStakeholder->getCreatedAt(),
  150. ////                $projectStakeholder->get(),
  151. ////            ]
  152. ////        });
  153. ////
  154. ////        return $this->projectStakeholders;
  155. //        return $this->projectStakeholders;
  156. //    }
  157.     public function addProjectStakeholder(ProjectStakeholders $projectStakeholder): self
  158.     {
  159.         if (!$this->project_stakeholders->contains($projectStakeholder)) {
  160.             $this->project_stakeholders[] = $projectStakeholder;
  161.             $projectStakeholder->addDependentQualification($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeProjectStakeholder(ProjectStakeholders $projectStakeholder): self
  166.     {
  167.         if ($this->project_stakeholders->removeElement($projectStakeholder)) {
  168.             $projectStakeholder->removeDependentQualification($this);
  169.         }
  170.         return $this;
  171.     }
  172. //    /**
  173. //     * @return Collection<int, WorkerInProject>
  174. //     */
  175. //    public function getWorkerInProjects(): Collection
  176. //    {
  177. //        return $this->workerInProjects;
  178. //
  179. //        return $this->workerInProjects->map( function(/**@var $workerInProject WorkerInProject*/ $workerInProject ){
  180. //            return [
  181. //                "id"=>$workerInProject->getId(),
  182. //                'project'=>[
  183. //                    "name"=>$workerInProject->getProject()->getProject()->getName(),
  184. //                ]
  185. //            ];
  186. //        });
  187. //
  188. //        // return new ArrayCollection([]); // $this->workerInProjects;
  189. //    }
  190.     public function addWorkerInProject(WorkerInProject $workerInProject): self
  191.     {
  192.         if (!$this->workerInProjects->contains($workerInProject)) {
  193.             $this->workerInProjects[] = $workerInProject;
  194.             $workerInProject->addAssignedQualification($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeWorkerInProject(WorkerInProject $workerInProject): self
  199.     {
  200.         if ($this->workerInProjects->removeElement($workerInProject)) {
  201.             $workerInProject->removeAssignedQualification($this);
  202.         }
  203.         return $this;
  204.     }
  205. //    /**
  206. //     * @return Collection<int, Projects>
  207. //     */
  208. //    public function getProjects(): Collection
  209. //    {
  210. //        return $this->projects;
  211. //        return $this->projects->map( function(/**@var $project Projects*/$project){
  212. //            return [
  213. //                "id"=>$project->getId(),
  214. //                'name'=>$project->getName()
  215. //            ];
  216. //        });
  217. //
  218. //        // return new ArrayCollection([]); // $this->projects;
  219. //    }
  220.     public function addProject(Projects $project): self
  221.     {
  222.         if (!$this->projects->contains($project)) {
  223.             $this->projects[] = $project;
  224.             $project->addDependentQualification($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeProject(Projects $project): self
  229.     {
  230.         if ($this->projects->removeElement($project)) {
  231.             $project->removeDependentQualification($this);
  232.         }
  233.         return $this;
  234.     }
  235. //    /**
  236. //     * @return Collection<int, AccessAddTimesheetTime>
  237. //     */
  238. //    public function getAccessAddTimesheetTimes(): Collection
  239. //    {
  240. //        return $this->accessAddTimesheetTimes;
  241. //    }
  242. //
  243. //    public function addAccessAddTimesheetTime(AccessAddTimesheetTime $accessAddTimesheetTime): self
  244. //    {
  245. //        if (!$this->accessAddTimesheetTimes->contains($accessAddTimesheetTime)) {
  246. //            $this->accessAddTimesheetTimes[] = $accessAddTimesheetTime;
  247. //            $accessAddTimesheetTime->setQualification($this);
  248. //        }
  249. //
  250. //        return $this;
  251. //    }
  252. //
  253. //    public function removeAccessAddTimesheetTime(AccessAddTimesheetTime $accessAddTimesheetTime): self
  254. //    {
  255. //        if ($this->accessAddTimesheetTimes->removeElement($accessAddTimesheetTime)) {
  256. //            // set the owning side to null (unless already changed)
  257. //            if ($accessAddTimesheetTime->getQualification() === $this) {
  258. //                $accessAddTimesheetTime->setQualification(null);
  259. //            }
  260. //        }
  261. //
  262. //        return $this;
  263. //    }
  264. }