<?php
namespace App\Entity;
use App\Repository\WorkersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WorkersRepository::class)]
class Workers
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $username;
#[ORM\Column(type: 'string', length: 255)]
private $full_name;
#[ORM\Column(type: 'integer', nullable: true)]
private $price_hour;
#[ORM\Column(type: 'integer', nullable: true)]
private $price_month;
#[ORM\Column(type: 'datetime', nullable: true)]
private $created;
#[ORM\OneToMany(targetEntity: WorkHours::class, mappedBy: 'worker', cascade: ['persist'])]
private $workhours;
#[ORM\OneToOne(targetEntity: User::class, mappedBy: 'worker', cascade: ['persist', 'remove'])]
private $user;
#[ORM\ManyToMany(targetEntity: Projects::class, mappedBy: 'workers')]
private $projects;
#[ORM\Column(type: 'boolean')]
private $active;
#[ORM\Column(type: 'integer', nullable: true)]
private $contribution;
public function __construct()
{
$this->workhours = new ArrayCollection();
$this->created = new \DateTime();
$this->projects = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getFullName(): ?string
{
return $this->full_name;
}
public function setFullName(string $full_name): self
{
$this->full_name = $full_name;
return $this;
}
public function getPriceHour(): ?int
{
return $this->price_hour;
}
public function setPriceHour(?int $price_hour): self
{
$this->price_hour = $price_hour;
return $this;
}
public function getPriceMonth(): ?int
{
return $this->price_month;
}
public function setPriceMonth(?int $price_month): self
{
$this->price_month = $price_month;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(?\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
/**
* @return Collection|WorkHours[]
*/
public function getWorkHours(): Collection
{
return new ArrayCollection();
}
/**
* @return Collection|WorkHours[]
*/
public function getWorkHoursAll(): Collection
{
return $this->workhours;
}
public function addWorkHour(WorkHours $workhour): self
{
$workhour->setWorker($this);
if (!$this->workhours->contains($workhour)) {
$this->workhours[] = $workhour;
$workhour->setWorker($this);
}
return $this;
}
public function removeWorkHour(WorkHours $workhour): self
{
$workhour->setWorker($this);
if ($this->workhours->removeElement($workhour)) {
// set the owning side to null (unless already changed)
if ($workhour->getWorker() === $this) {
$workhour->setWorker(null);
}
}
return $this;
}
public function __toString()
{
return $this->full_name;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
// unset the owning side of the relation if necessary
if ($user === null && $this->user !== null) {
$this->user->setWorker(null);
}
// set the owning side of the relation if necessary
if ($user !== null && $user->getWorker() !== $this) {
$user->setWorker($this);
}
$this->user = $user;
return $this;
}
/**
* @return Collection|Projects[]
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Projects $project): self
{
if (!$this->projects->contains($project)) {
$this->projects[] = $project;
$project->addWorker($this);
}
return $this;
}
public function removeProject(Projects $project): self
{
if ($this->projects->removeElement($project)) {
$project->removeWorker($this);
}
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getContribution(): ?int
{
return $this->contribution;
}
public function setContribution(?int $contribution): self
{
$this->contribution = $contribution;
return $this;
}
}