M
M
Maxim Zolotoy2019-12-08 14:39:10
Laravel
Maxim Zolotoy, 2019-12-08 14:39:10

How to get links of links when querying database in Laravel?

$category_group = CategoryGroup::with(['slides', 'categories'])
        ->where('path', '=', $category_group_alias)->first();

Here I get slides and categories links. For example, in each category there is also an item link. Can I somehow get them too at once in one request? Or then just loop around each category and get it separately?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NikSIk31, 2019-12-08
@spacenear

$category_group = CategoryGroup::with(['slides', 'categories' => function($query) {
        $query->with(...);
}])
        ->where('path', '=', $category_group_alias)->first();

if I'm not mistaken, something like this

V
vism, 2019-12-08
@vism

Lord, another hamster who does not read the documentation.
on the.

$category_group = CategoryGroup::with(['slides.items', 'categories.items'])
        ->where('path', '=', $category_group_alias)->first();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question