WIP: Implement model

This commit is contained in:
Björn Fromme
2023-09-12 18:17:24 +02:00
parent 35ca61d21b
commit f8c9ff82a5
35 changed files with 2935 additions and 0 deletions
+288
View File
@@ -8,6 +8,8 @@ use App\Entity\Embeddable\BankAccount;
use App\Entity\Embeddable\Communication;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\TeamerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
@@ -74,10 +76,45 @@ class Teamer implements TimestampableEntityInterface
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $remarks = null;
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Availability::class)]
private Collection $availabilities;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?Upload $photo = null;
#[ORM\OneToMany(mappedBy: 'teamer', targetEntity: Feedback::class)]
private Collection $feedback;
#[ORM\OneToMany(mappedBy: 'teamer', targetEntity: TrainingAttendance::class)]
private Collection $trainingAttendances;
#[ORM\OneToMany(mappedBy: 'teamer', targetEntity: License::class)]
private Collection $licenses;
#[ORM\ManyToMany(targetEntity: JobProfile::class)]
private Collection $jobProfiles;
#[ORM\ManyToMany(targetEntity: Assignment::class)]
private Collection $bookmarks;
#[ORM\OneToMany(mappedBy: 'teamer', targetEntity: Application::class)]
private Collection $applications;
#[ORM\OneToMany(mappedBy: 'teamer', targetEntity: Disposition::class)]
private Collection $dispositions;
public function __construct()
{
$this->uuid = Uuid::v4();
$this->status = static::STATUS_NEW;
$this->availabilities = new ArrayCollection();
$this->feedback = new ArrayCollection();
$this->trainingAttendances = new ArrayCollection();
$this->licenses = new ArrayCollection();
$this->jobProfiles = new ArrayCollection();
$this->bookmarks = new ArrayCollection();
$this->applications = new ArrayCollection();
$this->dispositions = new ArrayCollection();
}
public static function fromApiResponse(ProfileResponse $profileResponse): static
@@ -281,4 +318,255 @@ class Teamer implements TimestampableEntityInterface
return $this;
}
/**
* @return Collection<int, Availability>
*/
public function getAvailabilities(): Collection
{
return $this->availabilities;
}
public function addAvailability(Availability $availability): static
{
if (!$this->availabilities->contains($availability)) {
$this->availabilities->add($availability);
$availability->setOwner($this);
}
return $this;
}
public function removeAvailability(Availability $availability): static
{
if ($this->availabilities->removeElement($availability)) {
// set the owning side to null (unless already changed)
if ($availability->getOwner() === $this) {
$availability->setOwner(null);
}
}
return $this;
}
public function getPhoto(): ?Upload
{
return $this->photo;
}
public function setPhoto(?Upload $photo): static
{
$this->photo = $photo;
return $this;
}
/**
* @return Collection<int, Feedback>
*/
public function getFeedback(): Collection
{
return $this->feedback;
}
public function addFeedback(Feedback $feedback): static
{
if (!$this->feedback->contains($feedback)) {
$this->feedback->add($feedback);
$feedback->setTeamer($this);
}
return $this;
}
public function removeFeedback(Feedback $feedback): static
{
if ($this->feedback->removeElement($feedback)) {
// set the owning side to null (unless already changed)
if ($feedback->getTeamer() === $this) {
$feedback->setTeamer(null);
}
}
return $this;
}
/**
* @return Collection<int, TrainingAttendance>
*/
public function getTrainingAttendances(): Collection
{
return $this->trainingAttendances;
}
public function addTrainingAttendance(TrainingAttendance $trainingAttendance): static
{
if (!$this->trainingAttendances->contains($trainingAttendance)) {
$this->trainingAttendances->add($trainingAttendance);
$trainingAttendance->setTeamer($this);
}
return $this;
}
public function removeTrainingAttendance(TrainingAttendance $trainingAttendance): static
{
if ($this->trainingAttendances->removeElement($trainingAttendance)) {
// set the owning side to null (unless already changed)
if ($trainingAttendance->getTeamer() === $this) {
$trainingAttendance->setTeamer(null);
}
}
return $this;
}
/**
* @return Collection<int, License>
*/
public function getLicenses(): Collection
{
return $this->licenses;
}
public function addLicense(License $license): static
{
if (!$this->licenses->contains($license)) {
$this->licenses->add($license);
$license->setTeamer($this);
}
return $this;
}
public function removeLicense(License $license): static
{
if ($this->licenses->removeElement($license)) {
// set the owning side to null (unless already changed)
if ($license->getTeamer() === $this) {
$license->setTeamer(null);
}
}
return $this;
}
public function hasLicenseOfType(string $type): bool
{
foreach ($this->getLicenses() as $license) {
if ($type === $license->getType()) {
return true;
}
}
return false;
}
/**
* @return Collection<int, JobProfile>
*/
public function getJobProfiles(): Collection
{
return $this->jobProfiles;
}
public function addJobProfile(JobProfile $jobProfile): static
{
if (!$this->jobProfiles->contains($jobProfile)) {
$this->jobProfiles->add($jobProfile);
}
return $this;
}
public function removeJobProfile(JobProfile $jobProfile): static
{
$this->jobProfiles->removeElement($jobProfile);
return $this;
}
/**
* @return Collection<int, Assignment>
*/
public function getBookmarks(): Collection
{
return $this->bookmarks;
}
public function addBookmark(Assignment $bookmark): static
{
if (!$this->bookmarks->contains($bookmark)) {
$this->bookmarks->add($bookmark);
}
return $this;
}
public function removeBookmark(Assignment $bookmark): static
{
$this->bookmarks->removeElement($bookmark);
return $this;
}
/**
* @return Collection<int, Application>
*/
public function getApplications(): Collection
{
return $this->applications;
}
public function addApplication(Application $application): static
{
if (!$this->applications->contains($application)) {
$this->applications->add($application);
$application->setTeamer($this);
}
return $this;
}
public function removeApplication(Application $application): static
{
if ($this->applications->removeElement($application)) {
// set the owning side to null (unless already changed)
if ($application->getTeamer() === $this) {
$application->setTeamer(null);
}
}
return $this;
}
/**
* @return Collection<int, Disposition>
*/
public function getDispositions(): Collection
{
return $this->dispositions;
}
public function addDisposition(Disposition $disposition): static
{
if (!$this->dispositions->contains($disposition)) {
$this->dispositions->add($disposition);
$disposition->setTeamer($this);
}
return $this;
}
public function removeDisposition(Disposition $disposition): static
{
if ($this->dispositions->removeElement($disposition)) {
// set the owning side to null (unless already changed)
if ($disposition->getTeamer() === $this) {
$disposition->setTeamer(null);
}
}
return $this;
}
}