Reputation: 421
I have this curriculum type of data that should be displayed and unequally divided. See this
What I want is to achieve something like
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>{{ $subject->subject_code }}</td>
<td>{{ $subject->subject_description }}</td>
<td>{{ $subject->units }}</td>
<td></td>
<td>98</td>
</tr>
@endforeach
</tbody>
</table>
</div>
Upvotes: 1
Views: 6284
Reputation: 163798
Look at slice()
method. Example from documentation:
$collection = collect([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
$slice = $collection->slice(4);
$slice->all();
// [5, 6, 7, 8, 9, 10]
Upvotes: 2