Laravel:columnize()必须是类型数组,字符串给定,调用

时间:2015-04-05 11:58:02

标签: laravel laravel-4 eloquent laravel-5

我想在更新记录时调用此查询而不是ID,但我得到的错误是 columnize()必须是类型数组,字符串给定,调用

$user = Attendances::find(DB::raw('concat (firstname, " ",lastname)'), 'like', Input::get('student_name'))->where('section_name', 'like', Input::get('section_name'))->where('teacher_id', '=', Auth::user()->id)->where('subject_code', 'like', Input::get('subject_code'));

请求帮助:(

1 个答案:

答案 0 :(得分:5)

第一种方法也应该是where(),因为find()仅适用于主键。最后,还应调用get()first()来执行查询:

$user = Attendances::where(DB::raw('concat (firstname, " ",lastname)'), 'like', Input::get('student_name'))
       ->where('section_name', 'like', Input::get('section_name'))
       ->where('teacher_id', '=', Auth::user()->id)
       ->where('subject_code', 'like', Input::get('subject_code'))
       ->first();