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);
})->get()->pluck('fieldB')->toArray();
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!
The Laravel portal for problem solving, knowledge sharing and community building.
The community