<?php
namespace App\Core\Entity;
use App\Core\Entity\PuntuacionMaestro;
use App\Core\Entity\Subscripciones\PagoSubscripcion;
use App\Core\Entity\Subscripciones\HistorialPagoSubscripcion;
use App\Entity\CampusMaestro;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Core\Repository\MaestroRepository")
*/
class Maestro
{
const JSON_FIELDS = [
'id', 'user' => ['id'], 'maestroCursos' => ['id'], 'descripcionProfesional', 'profesion', 'sitioWeb', 'alias', 'puntuacionPromedio'
];
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToOne(targetEntity="App\Core\Entity\User", inversedBy="maestro", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\OneToMany(targetEntity="App\Core\Entity\MaestroCurso", mappedBy="maestro")
*/
private $maestroCursos;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $descripcionProfesional;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $profesion;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $sitioWeb;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $alias;
/**
* @ORM\OneToMany(targetEntity=PuntuacionMaestro::class, mappedBy="maestro", orphanRemoval=true)
*/
private $puntuacionesMaestro;
/**
* @ORM\OneToMany(targetEntity=PagoSubscripcion::class, mappedBy="maestro")
*/
private $pagosSubscripcion;
/**
* @ORM\OneToMany(targetEntity=HistorialPagoSubscripcion::class, mappedBy="maestro")
*/
private $historialPagosSubscripcion;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $puntuacionPromedio;
/**
* @ORM\OneToMany(targetEntity=CampusMaestro::class, mappedBy="maestro")
*/
private $campusMaestros;
public function __construct()
{
$this->maestroCursos = new ArrayCollection();
$this->puntuacionesMaestro = new ArrayCollection();
$this->pagosSubscripcion = new ArrayCollection();
$this->historialPagosSubscripcion = new ArrayCollection();
$this->campusMaestros = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection|MaestroCurso[]
*/
public function getMaestroCursos(): Collection
{
return $this->maestroCursos;
}
public function addMaestroCurso(MaestroCurso $maestroCurso): self
{
if (!$this->maestroCursos->contains($maestroCurso)) {
$this->maestroCursos[] = $maestroCurso;
$maestroCurso->setMaestro($this);
}
return $this;
}
public function removeMaestroCurso(MaestroCurso $maestroCurso): self
{
if ($this->maestroCursos->contains($maestroCurso)) {
$this->maestroCursos->removeElement($maestroCurso);
// set the owning side to null (unless already changed)
if ($maestroCurso->getMaestro() === $this) {
$maestroCurso->setMaestro(null);
}
}
return $this;
}
public function getCantidadCursosActivos() {
$relaciones = $this->getMaestroCursos();
$cantidad = 0;
for ($i = 0; $i < count($relaciones); $i++) {
$curso = $relaciones[$i]->getCurso();
if($curso->getEstado()) {
$cantidad++;
}
}
return $cantidad;
}
public function getCantidadCursosArchivados() {
return count($this->getMaestroCursos()) - $this->getCantidadCursosActivos();
}
public function getCantidadCursosActivosPrivados() {
$relaciones = $this->getMaestroCursos();
$cantidad = 0;
for ($i = 0; $i < count($relaciones); $i++) {
$curso = $relaciones[$i]->getCurso();
if($curso->getEstado() === 1 && $curso->getPrivado()) {
$cantidad++;
}
}
return $cantidad;
}
public function getCantidadCursosActivosAbiertos() {
$relaciones = $this->getMaestroCursos();
$cantidad = 0;
for ($i = 0; $i < count($relaciones); $i++) {
$curso = $relaciones[$i]->getCurso();
if($curso->getEstado() === 1 && !$curso->getPrivado()) {
$cantidad++;
}
}
return $cantidad;
}
public function getDescripcionProfesional(): ?string
{
return $this->descripcionProfesional;
}
public function setDescripcionProfesional(string $descripcionProfesional): self
{
if (trim($descripcionProfesional) === '') $descripcionProfesional = null;
$this->descripcionProfesional = $descripcionProfesional;
return $this;
}
public function getProfesion(): ?string
{
return $this->profesion;
}
public function setProfesion(?string $profesion): self
{
if (trim($profesion) === '') $profesion = null;
$this->profesion = $profesion;
return $this;
}
public function getSitioWeb(): ?string
{
return $this->sitioWeb;
}
public function setSitioWeb(string $sitioWeb): self
{
if (trim($sitioWeb) === '') $sitioWeb = null;
$this->sitioWeb = $sitioWeb;
return $this;
}
public function getAlias(): ?string
{
return $this->alias;
}
public function setAlias(string $alias): self
{
$this->alias = $alias;
return $this;
}
/**
* @return Collection|PuntuacionMaestro[]
*/
public function getPuntuacionesMaestro(): Collection
{
return $this->puntuacionesMaestro;
}
public function addPuntuacionesMaestro(PuntuacionMaestro $puntuacionesMaestro): self
{
if (!$this->puntuacionesMaestro->contains($puntuacionesMaestro)) {
$this->puntuacionesMaestro[] = $puntuacionesMaestro;
$puntuacionesMaestro->setMaestro($this);
}
return $this;
}
public function removePuntuacionesMaestro(PuntuacionMaestro $puntuacionesMaestro): self
{
if ($this->puntuacionesMaestro->removeElement($puntuacionesMaestro)) {
// set the owning side to null (unless already changed)
if ($puntuacionesMaestro->getMaestro() === $this) {
$puntuacionesMaestro->setMaestro(null);
}
}
return $this;
}
/**
* @return Collection|PagoSubscripcion[]
*/
public function getPagosSubscripcion(): Collection
{
return $this->pagosSubscripcion;
}
public function addPagosSubscripcion(PagoSubscripcion $pagosSubscripcion): self
{
if (!$this->pagosSubscripcion->contains($pagosSubscripcion)) {
$this->pagosSubscripcion[] = $pagosSubscripcion;
$pagosSubscripcion->setMaestro($this);
}
return $this;
}
public function removePagosSubscripcion(PagoSubscripcion $pagosSubscripcion): self
{
if ($this->pagosSubscripcion->removeElement($pagosSubscripcion)) {
// set the owning side to null (unless already changed)
if ($pagosSubscripcion->getMaestro() === $this) {
$pagosSubscripcion->setMaestro(null);
}
}
return $this;
}
/**
* @return Collection|HistorialPagoSubscripcion[]
*/
public function getHistorialPagosSubscripcion(): Collection
{
return $this->historialPagosSubscripcion;
}
/**
* @return ?float
*/
public function getPuntuacionPromedio(): ?float
{
return $this->puntuacionPromedio;
}
/**
* @param float $puntuacionPromedio
*/
public function setPuntuacionPromedio(float $puntuacionPromedio): void
{
$this->puntuacionPromedio = $puntuacionPromedio;
}
/**
* @return Collection<int, CampusMaestro>
*/
public function getCampusMaestros(): Collection
{
return $this->campusMaestros;
}
public function addCampusMaestro(CampusMaestro $campusMaestro): self
{
if (!$this->campusMaestros->contains($campusMaestro)) {
$this->campusMaestros[] = $campusMaestro;
$campusMaestro->setMaestro($this);
}
return $this;
}
public function removeCampusMaestro(CampusMaestro $campusMaestro): self
{
if ($this->campusMaestros->removeElement($campusMaestro)) {
// set the owning side to null (unless already changed)
if ($campusMaestro->getMaestro() === $this) {
$campusMaestro->setMaestro(null);
}
}
return $this;
}
}