When i run my project, i get the error
Object of class Illuminate\Support\Collection could not be converted to int
pointing to the code line
$classes =['0'=>'All']+ClassModel::pluck('name','code');
How can i get this solved?
PS: Laravel Beginner
Controller
public function show()
{
$selectedClass = Input::get('class',0);
$classes =['0'=>'All']+ClassModel::pluck('name','code');
if($selectedClass){
$Subjects= DB::table('Subject')
->join('Class', 'Subject.class', '=', 'Class.code')
->select('Subject.id', 'Subject.code','Subject.name','Subject.type', 'Subject.subgroup','Subject.stdgroup','Subject.totalfull',
'Subject.totalpass','Subject.gradeSystem','Subject.wfull', 'Subject.wpass','Subject.mfull','Subject.mpass','Class.Name as class','Subject.sfull','Subject.spass',
'Subject.pfull','Subject.ppass')
->where('Subject.class',$selectedClass)
->get();
}
else{
$Subjects= DB::table('Subject')
->join('Class', 'Subject.class', '=', 'Class.code')
->select('Subject.id', 'Subject.code','Subject.name','Subject.type', 'Subject.subgroup','Subject.stdgroup','Subject.totalfull',
'Subject.totalpass','Subject.gradeSystem','Subject.wfull', 'Subject.wpass','Subject.mfull','Subject.mpass','Class.Name as class','Subject.sfull','Subject.spass',
'Subject.pfull','Subject.ppass')
->get();
}
return View::Make('app.subjectList',compact('Subjects','classes','selectedClass'));
}
+
? – Alex Harris