0

dd result I have an API resulted as in picture. And I want to show the result in Laravel Blade. So I use this code:

    @if(isset($data))
        @foreach ($data as $had)
            <tr>
            <th scope="row">#</td>
            dd({{ $had['data']['NoHdt'] }});
            <td>{{ $had['data']['NoHdt'] }}</td>
            <td>{{ $had['data']['Kitab'] }}</td>
            <td>{{ $had['data']['Isi_Indonesia'] }}</td>
            </tr>
        @endforeach
    @endif
  </tbody>

But it always resulted

Undefined index: data

How to make it right?

2

2 Answers 2

2

Try this

@foreach ($apiResult['data'] as $data)
    <tr>
        <th scope="row">#</td>
        <td>{{ $data['NoHdt'] }}</td>
        <td>{{ $data['Kitab'] }}</td>
        <td>{{ $data['Isi_Indonesia'] }}</td>
    </tr>
@endforeach

where $apiResult correspond your shared dd screen https://i.sstatic.net/YQWfi.png

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this is the right answer for my case.
0

You can try the following instead.

@if(isset($data))
@foreach ($data as $had)
<tr>
    <th scope="row">#</td>
    dd({{ $had->NoHdt }});
    <td>{{ $had->NoHdt }}</td>
    <td>{{ $had->Kitab }}</td>
    <td>{{ $had->Isi_Indonesia }}</td>
</tr>
@endforeach
@endif
</tbody>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.