suppose i have a function like bellow (in Laravel 4.2):
public static function getResult($class_id,$section_id,$session,$term,$setTerm = ture)
{
$result = self::with('Student','Student.getClass','Student.getSection')
->where('class_id',$class_id)
->where('section_id',$section_id)
->where('exam_year',$session)
->where('term',$term)
->orderBy('class_roll','ASC')->get();
return $result;
}
so if $setTerm is set to false then (->where('term',$term)) should not be executed.
How to do that conditional things in Laravel during query building ?
Thanks