PHP Notice: Undefined index: Aluno in /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php on line 1821
PHP Warning: Invalid argument supplied for foreach() in /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php on line 1825
PHP Notice: Undefined index: Aluno in /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php on line 157
PHP Fatal error: Uncaught Error: Call to a member function setValue() on null in /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php:157
Stack trace:
#0 /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php(500): Doctrine\ORM\PersistentCollection->hydrateAdd(Object(Alura\Doctrine\Entity\Telefone))
#1 /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php(143): Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateRowData(Array, Array)
#2 /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php(270): Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateAllData()
#3 /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(977): Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(Object(Doctrine\DBAL\ForwardCompatibility\Result), Object(Doctrine\OR in /mnt/c/Dev/web/meu_dominio/doctrine/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php on line 157
<?php
namespace Alura\Doctrine\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Alura\Doctrine\Entity\Telefone;
/**
* @Entity
*/
class Aluno
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
private $id;
/**
* @Column(type="string")
*/
private $nome;
/**
* @OneToMany(targetEntity="Telefone", mappedBy="Aluno", cascade={"remove", "persist"})
*/
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;
}
}
<?php
namespace Alura\Doctrine\Entity;
use Alura\Doctrine\Entity\Aluno;
/**
* @Entity
*/
class Telefone
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
private $id_telefone;
/**
* @Column(type="string")
*/
private $numero;
/**
* @ManyToOne(targetEntity="Aluno")
*/
private $aluno;
public function getId(): int
{
return $this->id;
}
public function getNumero(): string
{
return $this->numero;
}
public function setNumero($numero): self
{
$this->numero = $numero;
return $this;
}
public function setAluno(Aluno $aluno)
{
$this->aluno = $aluno;
return $this;
}
public function getAluno(): Aluno
{
return $this->aluno;
}
}