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', '=', 'U.id');
$query->select('U.id 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 U.id = imagenes.id_fk)"));
$query->take(9);
$modelos = $query->get();
So I want make the same but with eloquent, if this is possibly of course.
Regards!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community