I have been practicing laravel
and there is something that does not work for me and I do not finish understanding or reviewing the documentation.
It turns out that I want to call the related objects between tables to get their other data, and when I do it with find
with a specific id for an object it works, but when I do it with each
for the whole list I returns the relationships as NULL
.
// Here I return NULL
$articles = Article::orderBy('id','DESC')->paginate(5);
$articles->each(function($articles){
$articles->categorie;
$articles->user;
});
dd($articles);
// But if I try it that way, it returns relationships well
$articles = Article::find(2);
$articles->categorie;
$articles->user;
dd($articles);