I'm new to Symfony and am trying to do a basic left join to pull in a clients name based on an client_id in the Jobs table.
App\Entity\Jobs
:
class Jobs
{
/**
* @ORM\Column(type="integer")
* @ORM\ManyToOne(targetEntity="App\Entity\Clients", inversedBy="jobs")
* @ORM\JoinColumn(nullable=false)
*/
private $client;
Should join to App\Entity\Clients
:
class Clients
{
/**
* @ORM\Column(type="integer")
* @ORM\OneToMany(targetEntity="App\Entity\Jobs", mappedBy="client")
*/
private $jobs;
In my App\Repository\JobsRepository
class, the following function is attempting the left join:
use App\Entity\Jobs;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
class JobsRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Jobs::class);
}
public function allWithClientName()
{
return $this->createQueryBuilder('job')
->leftJoin('job.client_id', 'client')
->getQuery()
->execute();
}
}
The error I'm getting returned is:
[Semantical Error] line 0, col 60 near 'client': Error: Class App\Entity\Jobs has no association named client_id
Any ideas? As far as my limited understanding goes, the annotations should form the required join.