Fatal error: Cannot declare class Alura\Doctrine\Entity\Aluno, because the name is already in use
Classe Aluno:
namespace Alura\Doctrine\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @Entity
*/
class Aluno
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
private $id;
/**
* @Column(type="string")
*/
private $nome;
/**
* @OneToMany(targetEntity="Telefone", mappedBy="Aluno")
*/
private $telefones;
public function __Construct()
{
$this->telefones = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function getNome(): string
{
return $this->nome;
}
public function setNome($nome) : self
{
$this->nome = $nome;
return $this;
}
public function addTelefone(Telefone $telefone)
{
$this->telefones->add($telefone);
$telefone->setAluno($this);
return $this;
}
public function getTelefones(): Collection
{
return $this->telefones;
}
}
Classe Telefone:
namespace Alura\Doctrine\Entity;
/**
* @Entity
*/
class Telefone
{
/**
* @Id
* @GenerationValue
* @Column(type="integer")
*/
private $id;
/**
* @Column(type="string")
*/
private $numero;
/**
* @ManyToOne(targetEntity="Aluno")
*/
private $aluno;
public function getId(): int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getNumero(): string
{
return $this->numero;
}
public function setNumero(string $numero): self
{
$this->numero = $numero;
return $this;
}
public function getAluno(): Aluno
{
return $this->aluno;
}
public function setAluno(Aluno $aluno): self
{
$this->aluno = $aluno;
return $this;
}
}