Penaf's avatar
Level 1

Pagination of data from a relation

            $galeriaInfo = Galeria::where('slug', 'LIKE', $slug)
                ->with(['multimedia'])
                ->withCount('multimedia')
                ->paginate(15);

Printing this $galeriaInfo I see the correct information on the screen ... info of the specific gallery and 15 images retrived from the other model. But how can I access the info on the blade template?

Doing

<h1>Galeria<span class="verde">{{ $galeriaInfo->nome }}</span></h1>

Gives: Undefined property: Illuminate\Pagination\LengthAwarePaginator::$nome

0 likes
5 replies
staudenmeir's avatar
Level 24

You have to use a loop:

@foreach($galeriaInfo as $galeria)
    {{ $galeria->nome }}
@endforeach
Penaf's avatar
Level 1

with the loops I can access the properties ... but $galeriaInfo->links() is not generating the pagination ...

jlrdw's avatar

is it galeriainfo->links()

Or galeriaInfo->links()

Does $galeriaInfo dd out corectly.

staudenmeir's avatar

What does {{ $galeriaInfo->links() }} show? Do you have more than 15 galleries?

Please or to participate in this conversation.