naekobest
5 months ago
934
20
Laravel

ForElse single ouput instead of multipe outputs - problem

Posted 5 months ago by naekobest

Hey there! Im currently trying to get behind why on earth there is only one output in my forelse loop

Thats what it looks like https://i.gyazo.com/f67f297054f22c3a9cc0fdd1c8d7a22e.png

populated exam table https://i.gyazo.com/3d472807740e23dd17af9117e0e38a7c.png

populated subject table https://gyazo.com/6c7455af1060e0bc103d836538ea43cd

populated topics table https://gyazo.com/0d9d7c0dffe9d0651170d12d926802d0

For each topic belonging to the/an exam i want a list item There should be 2 subjects for exam_id 3 (Vollzugsrecht)

@extends('layouts.app')

@section('content')
    <main role="main" class="container">
        <div class="container" style="display:inline-flex;">
            <div class="row w-100">
                <div class="col align-items-stretch">
                    <div class="row justify-content-center mt-4">
                        <p class="h1">Einf├╝hrungslehrgang</p>
                    </div>
                    @forelse ($topics as $topic)
                    @if ($topic->subject->exam->lehrgang == 'Einf├╝hrungslehrgang')
                      <div class="col-md-12 mt-4">
                        <div class="card">
                            <div class="card-body">
                                <h5 class="card-title font-weight-bold font-weight-bold">{{ $topic->subject->exam->name }}</h5>
                                <p class="card-text">
                                    <table class="table table-striped">
                                      <tbody>
                                        <tr>
                                          <td><a href="{{ route('subject') }}/{{ $topic->subject->id }}">{{ $topic->subject->name }}</a></td>
                                          <td><p class="card-text text-right"><small class="text-muted">Stand: {{ $topic->subject->updated_at->format('m/Y') }}</small></p></td>
                                        </tr>
                                      </tbody>
                                    </table>
                                </p>
                            </div>
                        </div>
                    </div>
                    @endif
                    @empty
                    @endforelse
                </div>
            </div>
        </div>
    </main>
@endsection

Please sign in or create an account to participate in this conversation.