mercredi 1 juin 2016

Divide collection into parts on laravel

I have this curriculum type of data that should be displayed and unequally divided. See this image

What I want is to achieve something like thisthis

Here's my code:

StudentController.php

public function show($id)
{
    $student = Student::with('course', 'course.curriculum', 'course.curriculum.subjects')->findOrFail($id);

    return view('students.show', compact('student'));
}

show.blade.php

<div class="panel-body">
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Course Code</th>
                <th>Descriptive Title</th>
                <th>Units</th>
                <th>Prerequisites</th>
                <th>Grade</th>
            </tr>
        </thead>

        <tbody>
            @foreach($student->course->curriculum->subjects as $subject)
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>98</td>
            </tr>
            @endforeach
        </tbody>
    </table>
</div>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire