Laravel Eloquent with and find

Try:

Article::with('category')->get()->find($ids);

You need to get the articles first before you can call find() I believe.

Warning: This retrieves every single article from the database and loads them all into memory, and then selects just one from all that data and returns it. That is probably not how you would want to handle this problem.


This will give you the results based on an array of IDs in Laravel 4

Article::whereIn('id', $ids)->with('category')->get();

Just for the posterity... other way you can do this is:

Article::with('category')->whereIn('id', $ids)->get();

This should be faster because it's leaving the query to the database manager