Support the ongoing development of Laravel.io →
Requests Database Eloquent
Last updated 2 years ago.
0

nobody knows ?

Last updated 2 years ago.
0

You could use Route::bind().

Route::bind('id', function($id) {
    return Post::with('media', 'user')->findOrFail($id);
});

Or you could pre-populate the $with property of the model. In this case every time you fetch a Post it will eager-load those too.

class Post extends Eloquent
{
    protected $with = ['media', 'user'];
}
Last updated 2 years ago.
0

perfect thanks a lot

Last updated 2 years ago.
0

thanks @tlgreg this helped me too.

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.