Monday, April 10, 2017

Join relation query for an Excel File

Hello i try to display some values from my Eloquent model "Licencies" who are in others tables in relation with an id but i get

Integrity constraint violation: 1052 Column 'id' in on clause is ambiguous

I'm not sure to make the join method correctly , someone could help me ?

Here my query :

 $licencies = Licencies::where('lb_assurance' , '=' , 'Lafont')
            ->leftJoin('activite_licencie' , 'id' , '=' , 'licencie.activite_licencie_id')
            ->leftJoin('saisons' , 'id' , '=' , 'licencie.saison_id')
            ->leftJoin('pays' , 'id' , '=' , 'licencie.pays_naissance_id')
            ->leftJoin('type_licence' , 'id' , '=' , 'licencie.type_licence_id')
            ->leftJoin('structures' , 'id' , '=' , 'licencie.structure.id')
            ->select('num_licence' , 'lb_nom' , 'lb_prenom' , 'dt_naissance' , 'lb_surclassement' , 'lb_assurance' , 'cd_dept_naissance' , 'activite_licencie.lb_activite' , 'saisons.lb_saison' , 'pays.fr' , 'type_licence.lb_type' , 'structures.nom_structure' )->get();



via Mathieu Mourareau

Advertisement