Hi, i am on my phone so i cant go into Detail, but you should look up "Working with pivots" and Eloquent relationships in the laravel docs.
I think you will find what you are looking for.
Good luck.
Sure you can:
$item = new Item;
$items = $item->whereIn($item->category()->getForeignKey(), function($query) use ($user) {
$query->select($user->categories()->getOtherKey())
->from($user->categories()->getTable())
->where($user->categories()->getForeignKey(), '=', $user->getKey());
})->orderBy('title')->get();
Ah, exactly what I was looking for, thank you!
I did read the documentation but it didn't specify how to get the local/foreign key from what I could find, and I guess I was just bad at reading the API docs. Feels a lot better to not have to mix hard-coded column and table names, kind of defeats a large part of Eloquents purpose :). I'll try it out.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community