Support the ongoing development of Laravel.io →
Database Eloquent

So I'm doing something like this:

$ImageCategory					= ImageCategory::where('styles.id', '=', $category->id)
																->leftJoin('images', 'styles.id', 'images.style_id')
																->get();

And I've also tried this:

$ImageCategory					= ImageCategory::leftJoin('images', 'id', 'images.style_id')->find($category->id);

Both return errors as invalid query syntax. Should work. Must I use a raw query for this to work or is there a more "eloquent" way of doing it?

Last updated 2 years ago.
0

Oh duh! Stupid typo. Should be:

$ImageCategory                  = ImageCategory::where('styles.id', '=', $category->id)
                                                                ->leftJoin('images', 'styles.id', '=', 'images.style_id')
                                                                ->get();
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2025 Laravel.io - All rights reserved.