Answer the question
In order to leave comments, you need to log in
Eloquent Many to Many - how to find records that are only related to certain other records?
Simplified View: Model and Properties
Route
id
City
id
name
RouteCityPivot
id
city_id
route_id
$route = Route::whereHas('cities', function ($q) use ($from, $to){
q->whereIn('name', [$from, $to]);
})->get();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question