jeudi 28 janvier 2021

How to get specific columns from relation table in laravel?

I am trying to fetch soecific columns data from relational table but it is giving me null

$allConsignments = Consignment::query();
$allConsignments->select(['id','customer_reference'])->with('customers:name,id')->orderBy('id', 'desc')->limit(5000)->get();

When I don't use select() then it gives correct data .

like this

$allConsignments = Consignment::query();
$allConsignments->with('customers:name,id')->orderBy('id', 'desc')->limit(5000)->get()

it is working but I also need specific columns from Consignment Table. what could be the reason?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3t1B4Lb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire