Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Elias177's avatar

Show laravel data with vue

Hey, i use laravel with Vue and i want to schow my data from database with vue componentes. But it only show the last of the database not every, why ?

        @foreach ($towyards as $towyard)

            <towyard-card
                vehicle="{{ $towyard->vehicle }}"
                sign="{{ $towyard->sign}}"
                customer="{{ $towyard->customer }}"
                employee="{{ $towyard->user->name }}"
                info="{{ $towyard->info }}"
                distance="{{ number_format($towyard->distance, 0, ',', '.') }}"
                status="{{ $towyard->status }}"
                time="{{ date('H:i', strtotime($towyard->created_at))}}"
            />
		@endforeach
0 likes
6 replies
tykus's avatar

How is $towyards variable assigned; what is the Eloquent query?

Elias177's avatar

@tykus In the Controller i do a database request (Towyard::where(... , ...)->get();)

krs's avatar

@Elias177 Try a @dd($towyards) before the @foreach loop. Does it show the whole collection?

Or post the whole query, so we can have a look...

krs's avatar

@Elias177 Okay, so the query is ok, what's with the card? Is it a blade component? Could you show the code from this? And another hint - what does the dev tools tell you about the resulting html - is there really only one card - code showing up, or is it invisible due to any opening-closing-tag-errors?

Please or to participate in this conversation.