Я пытаюсь изучить Symfony, и у меня проблема с получением данных в объекте.Дочерняя сущность получает только первую строку результата запроса.Как я могу получить правильные данные?
Здесь моя сущность команды:
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Races;
/**
* Teams
*
* @ORM\Table(name="teams",
indexes={@ORM\Index(name="idx_owned_by_coach_id",
columns={"owned_by_coach_id"}), @ORM\Index(name="fk_teams_races_idx", columns={"f_race_id"})})
* @ORM\Entity
*/
class Teams
{
/**
* @var int
*
* @ORM\Column(name="team_id", type="integer", nullable=false, options={"unsigned"=true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
private $teamId;
/**
* @var string|null
*
* @ORM\Column(name="name", type="string", length=60, nullable=true)
*/
private $name;
/**
* @var int|null
*
* @ORM\Column(name="treasury", type="bigint", nullable=true)
*/
private $treasury;
/**
* @var bool|null
*
* @ORM\Column(name="apothecary", type="boolean", nullable=true)
*/
private $apothecary;
/**
* @var int|null
*
* @ORM\Column(name="rerolls", type="integer", nullable=true, options={"unsigned"=true})
*/
private $rerolls;
/**
* @var bool|null
*
* @ORM\Column(name="ff_bought", type="boolean", nullable=true)
*/
private $ffBought;
/**
* @var int|null
*
* @ORM\Column(name="ass_coaches", type="integer", nullable=true, options={"unsigned"=true})
*/
private $assCoaches;
/**
* @var int|null
*
* @ORM\Column(name="cheerleaders", type="integer", nullable=true, options={"unsigned"=true})
*/
private $cheerleaders;
/**
* @var bool
*
* @ORM\Column(name="rdy", type="boolean", nullable=false, options={"default"="1"})
*/
private $rdy = '1';
/**
* @var bool
*
* @ORM\Column(name="retired", type="boolean", nullable=false)
*/
private $retired = '0';
/**
* @var bool|null
*
* @ORM\Column(name="ff", type="boolean", nullable=true)
*/
private $ff;
/**
* @var int|null
*
* @ORM\Column(name="tv", type="integer", nullable=true, options={"unsigned"=true})
*/
private $tv;
/**
* @var float|null
*
* @ORM\Column(name="elo", type="float", precision=10, scale=0, nullable=true)
*/
private $elo;
/**
* @var bool
*
* @ORM\Column(name="year", type="boolean", nullable=false)
*/
private $year;
/**
* @var int
*
* @ORM\Column(name="stadium", type="integer", nullable=false, options={"default"="99"})
*/
private $stadium = '99';
/**
* @var string
*
* @ORM\Column(name="stadium_name", type="string", length=60, nullable=false, options={"default"="green meadow"})
*/
private $stadiumName = 'green meadow';
/**
* @var \Coaches
*
* @ORM\ManyToOne(targetEntity="Coaches")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="owned_by_coach_id", referencedColumnName="coach_id")
* })
*/
private $ownedByCoach;
/**
* @var \Races
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\OneToOne(targetEntity="Races", fetch="EAGER")
* @ORM\JoinColumn(name="f_race_id", referencedColumnName="race_id")
*/
private $fRace;
public function getTeamId(): ?int
{
return $this->teamId;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getTreasury(): ?int
{
return $this->treasury;
}
public function setTreasury(?int $treasury): self
{
$this->treasury = $treasury;
return $this;
}
public function getApothecary(): ?bool
{
return $this->apothecary;
}
public function setApothecary(?bool $apothecary): self
{
$this->apothecary = $apothecary;
return $this;
}
public function getRerolls(): ?int
{
return $this->rerolls;
}
public function setRerolls(?int $rerolls): self
{
$this->rerolls = $rerolls;
return $this;
}
public function getFfBought(): ?bool
{
return $this->ffBought;
}
public function setFfBought(?bool $ffBought): self
{
$this->ffBought = $ffBought;
return $this;
}
public function getAssCoaches(): ?int
{
return $this->assCoaches;
}
public function setAssCoaches(?int $assCoaches): self
{
$this->assCoaches = $assCoaches;
return $this;
}
public function getCheerleaders(): ?int
{
return $this->cheerleaders;
}
public function setCheerleaders(?int $cheerleaders): self
{
$this->cheerleaders = $cheerleaders;
return $this;
}
public function getRdy(): ?bool
{
return $this->rdy;
}
public function setRdy(bool $rdy): self
{
$this->rdy = $rdy;
return $this;
}
public function getRetired(): ?bool
{
return $this->retired;
}
public function setRetired(bool $retired): self
{
$this->retired = $retired;
return $this;
}
public function getFf(): ?bool
{
return $this->ff;
}
public function setFf(?bool $ff): self
{
$this->ff = $ff;
return $this;
}
public function getTv(): ?int
{
return $this->tv;
}
public function setTv(?int $tv): self
{
$this->tv = $tv;
return $this;
}
public function getElo(): ?float
{
return $this->elo;
}
public function setElo(?float $elo): self
{
$this->elo = $elo;
return $this;
}
public function getYear(): ?bool
{
return $this->year;
}
public function setYear(bool $year): self
{
$this->year = $year;
return $this;
}
public function getStadium(): ?int
{
return $this->stadium;
}
public function setStadium(int $stadium): self
{
$this->stadium = $stadium;
return $this;
}
public function getStadiumName(): ?string
{
return $this->stadiumName;
}
public function setStadiumName(string $stadiumName): self
{
$this->stadiumName = $stadiumName;
return $this;
}
public function getOwnedByCoach(): ?Coaches
{
return $this->ownedByCoach;
}
public function setOwnedByCoach(?Coaches $ownedByCoach): self
{
$this->ownedByCoach = $ownedByCoach;
return $this;
}
public function getFRace(): ?Races
{
return $this->fRace;
}
public function setFRace(?Races $fRace): self
{
$this->fRace = $fRace;
return $this;
}
}
Здесь моя сущность расы:
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Races
*
* @ORM\Table(name="races")
* @ORM\Entity
*/
class Races
{
/**
* @var bool
*
* @ORM\Column(name="race_id", type="boolean", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $raceId;
/**
* @var string|null
*
* @ORM\Column(name="name", type="string", length=60, nullable=true)
*/
private $name;
/**
* @var int|null
*
* @ORM\Column(name="cost_rr", type="integer", nullable=true, options={"unsigned"=true})
*/
private $costRr;
/**
* @var string|null
*
* @ORM\Column(name="icon", type="string", length=45, nullable=true)
*/
private $icon;
public function getRaceId(): ?bool
{
return $this->raceId;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getCostRr(): ?int
{
return $this->costRr;
}
public function setCostRr(?int $costRr): self
{
$this->costRr = $costRr;
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
}
как мне получить данные в моем контроллере
$teams = $this->getDoctrine()
->getRepository(Teams::class)
->findAll();
Вот что я получаю:
Дочерняя сущность всегда показывает первую строку ....