Support the ongoing development of →
Eloquent Laravel Database
Last updated 2 years ago.

Hi Nima,

Get the results first and then pluck the field from the collection. So like this:

$Result = TableA::with('tableB')
    ->where('fieldA', $valueA)->whereHas('tableB', function($query){
    // Now querying on tableB
    $query->where('fieldB', $valueB);

This will use the collection's pluck method, not the query builder's. I don't know if that's what you're looking for, but I assume it'll work just as well.


Sign in to participate in this thread!


Your banner here too?

Nima webcoweb Joined 14 Aug 2018


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.