<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\PlayerRepository")
* @Vich\Uploadable
*/
class Player
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastname;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Position", inversedBy="players")
*/
private $position;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $age;
/**
* @ORM\Column(type="decimal", precision=5, scale=2, nullable=true)
*/
private $weight;
/**
* @ORM\Column(type="decimal", precision=5, scale=2, nullable=true)
*/
private $height;
/**
* @ORM\Column(type="decimal", precision=5, scale=2, nullable=true)
*/
private $shoes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Vich\UploadableField(mapping="player_images", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime
*/
private $updatedAt;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $skillfulLeg;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SeasonPlayer", mappedBy="player", orphanRemoval=true)
*/
private $seasonPlayers;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Convocatoria", mappedBy="players")
*/
private $convocatorias;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\TrainingAsist", mappedBy="players")
*/
private $trainingAsists;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Position")
*/
private $secondary_position;
/**
* @ORM\Column(type="boolean")
*/
private $isActive = true;
/**
* @ORM\OneToMany(targetEntity=PlayerJustification::class, mappedBy="player", orphanRemoval=true)
*/
private $justification;
/**
* @ORM\Column(type="date",nullable=true)
*/
private $birth_date;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Country", inversedBy="player")
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $numberDocument;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $healthCard;
/**
* @ORM\Column(type="datetime", length=255,nullable=true)
* @var \DateTime
*/
private $dateOfBirth;
/**
* @ORM\Column(type="datetime", length=255,nullable=true)
* @var \DateTime
*/
private $medicalReviewDate;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $lastClub;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime
*/
private $deletedAt;
public function __construct()
{
$this->seasonPlayers = new ArrayCollection();
$this->convocatorias = new ArrayCollection();
$this->trainingAsists = new ArrayCollection();
$this->justification = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName($name): self
{
$this->name = $name;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname($lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getPosition(): ?Position
{
return $this->position;
}
public function setPosition(?Position $position): self
{
$this->position = $position;
return $this;
}
public function getAge(): ?int
{
return $this->age;
}
public function setAge($age): self
{
$this->age = $age;
return $this;
}
public function getWeight(): ?string
{
return $this->weight;
}
public function setWeight($weight): self
{
$this->weight = $weight;
return $this;
}
public function getHeight(): ?string
{
return $this->height;
}
public function setHeight($height): self
{
$this->height = $height;
return $this;
}
public function getShoes(): ?string
{
return $this->shoes;
}
public function setShoes($shoes): self
{
$this->shoes = $shoes;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
{
return $this->updatedAt;
}
/**
* @param \DateTime $updatedAt
* @return Player
*/
public function setUpdatedAt(\DateTime $updatedAt): Player
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return mixed
*/
public function getSkillfulLeg()
{
return $this->skillfulLeg;
}
/**
* @param mixed $skillfulLeg
*/
public function setSkillfulLeg($skillfulLeg): void
{
$this->skillfulLeg = $skillfulLeg;
}
/**
* @param File|null $image
* @return Player
*/
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
return $this;
}
public function getImageFile()
{
return $this->imageFile;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
/**
* @return Collection|SeasonPlayer[]
*/
public function getSeasonPlayers(): Collection
{
return $this->seasonPlayers;
}
public function addSeasonPlayer(SeasonPlayer $seasonPlayer): self
{
if (!$this->seasonPlayers->contains($seasonPlayer)) {
$this->seasonPlayers[] = $seasonPlayer;
$seasonPlayer->setPlayer($this);
}
return $this;
}
public function removeSeasonPlayer(SeasonPlayer $seasonPlayer): self
{
if ($this->seasonPlayers->contains($seasonPlayer)) {
$this->seasonPlayers->removeElement($seasonPlayer);
// set the owning side to null (unless already changed)
if ($seasonPlayer->getPlayer() === $this) {
$seasonPlayer->setPlayer(null);
}
}
return $this;
}
/**
* @return Collection|Convocatoria[]
*/
public function getConvocatorias(): Collection
{
return $this->convocatorias;
}
public function addConvocatoria(Convocatoria $convocatoria): self
{
if (!$this->convocatorias->contains($convocatoria)) {
$this->convocatorias[] = $convocatoria;
$convocatoria->addPlayer($this);
}
return $this;
}
public function removeConvocatoria(Convocatoria $convocatoria): self
{
if ($this->convocatorias->contains($convocatoria)) {
$this->convocatorias->removeElement($convocatoria);
$convocatoria->removePlayer($this);
}
return $this;
}
/**
* @return Collection|TrainingAsist[]
*/
public function getTrainingAsists(): Collection
{
return $this->trainingAsists;
}
public function addTrainingAsist(TrainingAsist $trainingAsist): self
{
if (!$this->trainingAsists->contains($trainingAsist)) {
$this->trainingAsists[] = $trainingAsist;
$trainingAsist->addPlayer($this);
}
return $this;
}
public function removeTrainingAsist(TrainingAsist $trainingAsist): self
{
if ($this->trainingAsists->contains($trainingAsist)) {
$this->trainingAsists->removeElement($trainingAsist);
$trainingAsist->removePlayer($this);
}
return $this;
}
public function __toArray($imagePath)
{
return [
"id" => $this->getId(),
"name" => $this->getName(),
"lastname" => $this->getLastname(),
"positionSlug" => !empty($this->getPosition()) ? $this->getPosition()->getSlug() : "",
"position" => !empty($this->getPosition()) ? $this->getPosition()->getSlugTranslation() : "",
"positionKey" => !empty($this->getPosition()) ? $this->getPosition()->getFieldPosition() : null,
"positionSecondary" => !empty($this->getSecondaryPosition()) ? $this->getSecondaryPosition()->getSlugTranslation() : "",
"positionSecondarySlug" => !empty($this->getSecondaryPosition()) ? $this->getSecondaryPosition()->getSlug() : "",
"positionSecondaryKey" => !empty($this->getSecondaryPosition()) ? $this->getSecondaryPosition()->getFieldPosition() : null,
"age" => $this->getAge(),
"weight" => $this->getWeight(),
"height" => $this->getHeight(),
"shoes" => round($this->getShoes()),
"image" => !empty($this->getImage()) ? $imagePath . $this->getImage() : "",
"skillfulLeg" => $this->getSkillfulLeg(),
"birthDate" => !empty($this->getBirthDate()) ? $this->getBirthDate()->format('Y-m-d') : null,
"phone" => $this->getPhone(),
"email" => $this->getEmail(),
"numberDocument" => $this->getNumberDocument(),
"healthCard" => $this->getHealthCard(),
"dateOfBirth" => $this->getDateOfBirth() ? $this->getDateOfBirth()->format('Y-m-d'): null,
"medicalReviewDate" => $this->getMedicalReviewDate() ? $this->getMedicalReviewDate()->format('Y-m-d'): null,
"lastClub" => $this->getLastClub()
];
}
public function getSecondaryPosition(): ?Position
{
return $this->secondary_position;
}
public function setSecondaryPosition(?Position $secondary_position): self
{
$this->secondary_position = $secondary_position;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection|PlayerJustification[]
*/
public function getJustification(): Collection
{
return $this->justification;
}
public function addJustification(PlayerJustification $justification): self
{
if (!$this->justification->contains($justification)) {
$this->justification[] = $justification;
$justification->setPlayer($this);
}
return $this;
}
public function removeJustification(PlayerJustification $justification): self
{
if ($this->justification->contains($justification)) {
$this->justification->removeElement($justification);
// set the owning side to null (unless already changed)
if ($justification->getPlayer() === $this) {
$justification->setPlayer(null);
}
}
return $this;
}
public function getBirthDate(): ?\DateTimeInterface
{
return $this->birth_date;
}
public function setBirthDate(\DateTimeInterface $birth_date): self
{
$this->birth_date = $birth_date;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getNumberDocument(): ?string
{
return $this->numberDocument;
}
public function setNumberDocument(?string $numberDocument): self
{
$this->numberDocument = $numberDocument;
return $this;
}
public function getHealthCard(): ?string
{
return $this->healthCard;
}
public function setHealthCard(?string $healtCard): self
{
$this->healthCard = $healtCard;
return $this;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function getDateOfBirth(): ?DateTime
{
return $this->dateOfBirth;
}
public function setDateOfBirth(?DateTime $dateOfBirth): self
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
public function getMedicalReviewDate(): ?DateTime
{
return $this->medicalReviewDate;
}
public function setMedicalReviewDate(?DateTime $medicalReviewDate): self
{
$this->medicalReviewDate = $medicalReviewDate;
return $this;
}
public function getLastClub(): ?string
{
return $this->lastClub;
}
public function setLastClub(?string $lastClub): self
{
$this->lastClub = $lastClub;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
}