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

To better understand what you need, can you post how you did it without elequent


Hi Bostjan, of course, I change a little the Database but this is the same:

With this I get 9 users with name, lastname and the photo from imagenes table (photo table actually) while column perfil in imagenes table is true

This code is from my old site in laravel 4 without use Eloquent there.

$query = DB::table('users as U');
$query->leftJoin('imagenes as I', 'I.id_fk', '=', '');

$query->select(' as id', 'U.nombre as nombre', 'U.apellido as apellido', 'I.nombre as imagen');

$query->where('U.verificado', 1);
$query->where('I.perfil', 1);

$query->where('I.id_fk', '=', DB::raw("(SELECT MIN(id) FROM imagenes WHERE = imagenes.id_fk)"));


$modelos = $query->get();

So I want make the same but with eloquent, if this is possibly of course.



Sign in to participate in this thread!


Your banner here too?


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.