A
A
Anton Shelestov2017-03-01 14:22:56
MySQL
Anton Shelestov, 2017-03-01 14:22:56

How to properly write select with nested select in laravel?

Hello!
There is this request:

$doctors = \App\Doctor::select('doctors.*', \DB::raw('(SELECT file_name FROM images where doctors.id = images.doctor_id AND images.type = "doctor_face") as face_foto'))
     ->....
     ->paginate(10);

there is a lot of code in the middle, I didn’t display it, it’s not needed.
The question is whether it is possible to rewrite select using laravel without raw sql?
Otherwise, there will be several such nested selects, and for each one you will have to write such code ...
Thank you

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question