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@ref",
  34.      *     "qualification@base",
  35.      *     "qualification@core"
  36.      *
  37.      * })
  38.      */
  39.     private $id;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, unique=true)
  42.      * @Groups({
  43.      *     "qualifications.base",
  44.      *     "project.qualifications",
  45.      *     "partner.joined.projects.depended.qualifications",
  46.      *     "stakeholder.selected.core.project.manage",
  47.      *     "worker.manage.base",
  48.      *     "worker.manage.selected.worker.in.project",
  49.      *     "worker.manage.joined.projects",
  50.      *     "selected.partner.project.for.worker",
  51.      *
  52.      *     "qualification@base",
  53.      *     "qualification@core"
  54.      * })
  55.      */
  56.     private $name;
  57.     /**
  58.      * @ORM\ManyToMany(targetEntity=Worker::class, mappedBy="qualifications")
  59.      */
  60.     private $workers;
  61.     /**
  62.      * @ORM\Column(type="string", length=255, nullable=true )
  63.      * @Groups({
  64.      *     "qualifications.base",
  65.      *     "project.qualifications",
  66.      *     "partner.joined.projects.depended.qualifications",
  67.      *     "stakeholder.selected.core.project.manage",
  68.      *     "worker.manage.selected.worker.in.project",
  69.      *     "worker.manage.joined.projects",
  70.      *
  71.      *     "qualification@core"
  72.      * })
  73.      */
  74.     private $color;
  75.     /**
  76.      * Meslek grubunun VARSAYILAN saat ucreti (on tanim). Calisan/aktivite bazinda ezilebilir
  77.      * (`worker_activities.hourly_rate`) — burasi yalnizca katalogdaki fabrika degeridir.
  78.      *
  79.      * 🪤 AYRI serialization grubu (`qualification@core` DEGIL): ucret maas hassasiyetinde bir
  80.      *    bilgidir, oysa katalog listesi her yerden (yetenek secim modali, proje, calisan) ayni
  81.      *    uctan okunuyor. ReferenceController grubu yalniz `desktop_settings:r` olana ekler.
  82.      *
  83.      * @ORM\Column(type="float", nullable=true)
  84.      * @Groups({
  85.      *     "qualification@rate"
  86.      * })
  87.      */
  88.     private $default_hourly_rate;
  89.     /**
  90.      * @ORM\ManyToMany(targetEntity=ProjectStakeholders::class, mappedBy="dependent_qualifications" )
  91.      */
  92.     private $project_stakeholders;
  93.     /**
  94.      * @ORM\ManyToMany(targetEntity=WorkerInProject::class, mappedBy="assigned_qualifications")
  95.      */
  96.     private $workerInProjects;
  97.     /**
  98.      * @ORM\ManyToMany(targetEntity=Projects::class, mappedBy="dependent_qualifications")
  99.      */
  100.     private $projects;
  101. //    /**
  102. //     * @ORM\OneToMany(targetEntity=AccessAddTimesheetTime::class, mappedBy="qualification")
  103. //     */
  104.     # private $accessAddTimesheetTimes;
  105.     public function __construct()
  106.     {
  107.         $this->workers = new ArrayCollection();
  108.         $this->project_stakeholders = new ArrayCollection();
  109.         $this->workerInProjects = new ArrayCollection();
  110.         $this->projects = new ArrayCollection();
  111.         # $this->accessAddTimesheetTimes = new ArrayCollection();
  112.     }
  113.     public function getId(): ?int
  114.     {
  115.         return $this->id;
  116.     }
  117.     public function getName(): ?string
  118.     {
  119.         return $this->name;
  120.     }
  121.     public function setName(string $name): self
  122.     {
  123.         $this->name = $name;
  124.         return $this;
  125.     }
  126. //    /**
  127. //     * @return Collection<int, Worker>
  128. //     */
  129. //    public function getWorkers(): ?Collection
  130. //    {
  131. //        return $this->workers;
  132. //    }
  133.     public function addWorker(Worker $worker): self
  134.     {
  135.         if (!$this->workers->contains($worker)) {
  136.             $this->workers[] = $worker;
  137.             $worker->addQualification($this);
  138.         }
  139.         return $this;
  140.     }
  141.     public function removeWorker(Worker $worker): self
  142.     {
  143.         if ($this->workers->removeElement($worker)) {
  144.             $worker->removeQualification($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function getColor(): ?string
  149.     {
  150.         return $this->color;
  151.     }
  152.     public function setColor(?string $color): self
  153.     {
  154.         $this->color = $color;
  155.         return $this;
  156.     }
  157.     public function getDefaultHourlyRate(): ?float
  158.     {
  159.         return $this->default_hourly_rate;
  160.     }
  161.     public function setDefaultHourlyRate(?float $default_hourly_rate): self
  162.     {
  163.         $this->default_hourly_rate = $default_hourly_rate;
  164.         return $this;
  165.     }
  166. //    /**
  167. //     * @return Collection<int, ProjectStakeholders>
  168. //     */
  169. //    public function getProjectStakeholders(): Collection
  170. //    {
  171. //
  172. ////        return $this->projectStakeholders->map(function(/**@var $projectStakeholder ProjectStakeholders*/$projectStakeholder){
  173. ////            return [
  174. ////                'id' => $projectStakeholder->getId(),
  175. ////                $projectStakeholder->getCreatedAt(),
  176. ////                $projectStakeholder->get(),
  177. ////            ]
  178. ////        });
  179. ////
  180. ////        return $this->projectStakeholders;
  181. //        return $this->projectStakeholders;
  182. //    }
  183.     public function addProjectStakeholder(ProjectStakeholders $projectStakeholder): self
  184.     {
  185.         if (!$this->project_stakeholders->contains($projectStakeholder)) {
  186.             $this->project_stakeholders[] = $projectStakeholder;
  187.             $projectStakeholder->addDependentQualification($this);
  188.         }
  189.         return $this;
  190.     }
  191.     public function removeProjectStakeholder(ProjectStakeholders $projectStakeholder): self
  192.     {
  193.         if ($this->project_stakeholders->removeElement($projectStakeholder)) {
  194.             $projectStakeholder->removeDependentQualification($this);
  195.         }
  196.         return $this;
  197.     }
  198. //    /**
  199. //     * @return Collection<int, WorkerInProject>
  200. //     */
  201. //    public function getWorkerInProjects(): Collection
  202. //    {
  203. //        return $this->workerInProjects;
  204. //
  205. //        return $this->workerInProjects->map( function(/**@var $workerInProject WorkerInProject*/ $workerInProject ){
  206. //            return [
  207. //                "id"=>$workerInProject->getId(),
  208. //                'project'=>[
  209. //                    "name"=>$workerInProject->getProject()->getProject()->getName(),
  210. //                ]
  211. //            ];
  212. //        });
  213. //
  214. //        // return new ArrayCollection([]); // $this->workerInProjects;
  215. //    }
  216.     public function addWorkerInProject(WorkerInProject $workerInProject): self
  217.     {
  218.         if (!$this->workerInProjects->contains($workerInProject)) {
  219.             $this->workerInProjects[] = $workerInProject;
  220.             $workerInProject->addAssignedQualification($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeWorkerInProject(WorkerInProject $workerInProject): self
  225.     {
  226.         if ($this->workerInProjects->removeElement($workerInProject)) {
  227.             $workerInProject->removeAssignedQualification($this);
  228.         }
  229.         return $this;
  230.     }
  231. //    /**
  232. //     * @return Collection<int, Projects>
  233. //     */
  234. //    public function getProjects(): Collection
  235. //    {
  236. //        return $this->projects;
  237. //        return $this->projects->map( function(/**@var $project Projects*/$project){
  238. //            return [
  239. //                "id"=>$project->getId(),
  240. //                'name'=>$project->getName()
  241. //            ];
  242. //        });
  243. //
  244. //        // return new ArrayCollection([]); // $this->projects;
  245. //    }
  246.     public function addProject(Projects $project): self
  247.     {
  248.         if (!$this->projects->contains($project)) {
  249.             $this->projects[] = $project;
  250.             $project->addDependentQualification($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeProject(Projects $project): self
  255.     {
  256.         if ($this->projects->removeElement($project)) {
  257.             $project->removeDependentQualification($this);
  258.         }
  259.         return $this;
  260.     }
  261. //    /**
  262. //     * @return Collection<int, AccessAddTimesheetTime>
  263. //     */
  264. //    public function getAccessAddTimesheetTimes(): Collection
  265. //    {
  266. //        return $this->accessAddTimesheetTimes;
  267. //    }
  268. //
  269. //    public function addAccessAddTimesheetTime(AccessAddTimesheetTime $accessAddTimesheetTime): self
  270. //    {
  271. //        if (!$this->accessAddTimesheetTimes->contains($accessAddTimesheetTime)) {
  272. //            $this->accessAddTimesheetTimes[] = $accessAddTimesheetTime;
  273. //            $accessAddTimesheetTime->setQualification($this);
  274. //        }
  275. //
  276. //        return $this;
  277. //    }
  278. //
  279. //    public function removeAccessAddTimesheetTime(AccessAddTimesheetTime $accessAddTimesheetTime): self
  280. //    {
  281. //        if ($this->accessAddTimesheetTimes->removeElement($accessAddTimesheetTime)) {
  282. //            // set the owning side to null (unless already changed)
  283. //            if ($accessAddTimesheetTime->getQualification() === $this) {
  284. //                $accessAddTimesheetTime->setQualification(null);
  285. //            }
  286. //        }
  287. //
  288. //        return $this;
  289. //    }
  290. }