H
H
Harconnen2015-01-11 14:35:59
MySQL
Harconnen, 2015-01-11 14:35:59

How is it possible to make a request to the database in Laravel?

Good afternoon!
Help, I can not understand where to dig.
Here is the code:

$places = Place::whereIn('id', $result)
                        ->where('active', '=', true)
                        ->Join('regions', 'places.region_id', '=', 'regions.id')
                        ->orderBy('rating')
                        ->paginate(10);

with Join without whereIn - works
with whereIn without Join - works
But they don't work together.
Sincerely, Konstantin.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gladkovskiy, 2015-01-11
@Harconnen

If you want to get places, then you need to determine what you want to see as a result (select()) and refine the conditions depending on this.

$places = Place::whereIn('places.id', $result)
                        ->where('places.active', '=', true)
                        ->Join('regions', 'places.region_id', '=', 'regions.id')
                        ->orderBy('places.rating')
                        ->select(['places.*'])
                        ->paginate(10);

E
Eugene, 2015-01-11
@Nc_Soft

Maybe it's worth configuring the relay?
Or get a sql query, orm is needed to simplify life, and not vice versa.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question