This is my sum query, It actually sums up the number of units and a subject price of a specific student.
$subjects = DB::table('subjects')
->join('subjectblocking', 'subjects.subjectcode', '=', 'subjectblocking.subjectcode')
->join('grades', 'subjectblocking.blockcode', '=', 'grades.blockcode')
->select('subjects.numofunit as total_units','subjects.price as total_tuition')
->orWhere(function($query)
{
$query->where('grades.studentid', '=', '2013-F0218')
->where('sem', '=', '1')
->where('sy', '=', '2013-2014');
})
->sum('subjects.numofunit','subjects.price');
return View::make('users.assessment')->with('subjects', $subjects);
This is how I foreach it in blade
@foreach ($subjects as $subject)
{
<tr>
<td>{{$subject->total_units}}</td>
<td>{{$subject->total_tuition}}</td>
</tr>
}
@endforeach
However it tells me that
Invalid argument supplied for foreach()