I wanted to sum up the numofunit
and total price
in the subject table. I already did what I was told to do on google, however I still encountered some errors which is vague to me. I wanted to know if I am doing this right, since I am still new in querying db in laravel. I honestly am not sure of the syntax
This is a snippet of the query:
$results = 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')
->sum('subjects.numofunit','subjects.price')
->orWhere(function($query)
{
$query->where('grades.studentid', '=', '2013-F0218')
->where('sem', '=', '1')
->where('sy', '=', '2013-2014');
})
->get();
This is the error that I have encountered:
Call to a member function orWhere() on a non-object On line 72: which is ->orWhere(function($query)
I believe that I declared $query
, so i'm not sure why I'm still receiving errors