Is paint_color on the Color class or on the Car class?
Feb 16, 2021
15
Level 1
Laravel query using whereHas
I have 2 models: car painted color, and cars
public function color()
{
return $this->hasOne(Colors::class)->latest();
}
I need to search the latest painted car color but with whereHas, it's searching all colors
$colors = ['black', 'white'];
$cars->whereHas('color', function($cars) use ($colors) {
return $cars->whereIn('paint_color', $colors);
});
How can I make whereIn to only query on the latest row?
Please or to participate in this conversation.