Когда я запускаю свой проект, я получаю сообщение об ошибке
Объект класса Illuminate \ Support \ Collection не может быть преобразован в int
указывая на строку кода
$classes =['0'=>'All']+ClassModel::pluck('name','code');
Как я могу решить эту проблему?
PS: Laravel Beginner
Контроллер
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'));
}