mercredi 28 novembre 2018

how to select field from other table laravel

i want to select a field from another table, how i can do it in laravel, im still newby in laravel.

here my code

$company = Company::select(
['companies.id', 'companies.CompanyName', 'companies.Discount', 'companies.OrgNumber', 'companies.ExternalID', 'companies.DCity'])
 ->join('companystructures AS cs', 'cs.ChildCompanyID', '=', 'companies.id')
 ->where(['companies.Active' => 1, 'cs.Active' => 1])->get();

i want to add more select to field ParentCompanyID from table companystructures.

i try like this but got error

$company = Company::select(['companies.id', 'companies.CompanyName', 'companies.Discount', 'companies.OrgNumber','companies.ExternalID', 'companies.DCity', '**companystructures.ParentCompanyID**'])
 ->join('companystructures AS cs', 'cs.ChildCompanyID', '=', 'companies.id')
 ->where(['companies.Active' => 1, 'cs.Active' => 1])->get();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire