Search code examples
mongodbselectlaravel-4jenssegers-mongodb

Raw select using jenssegers Laravel-MongoDB


I add jenssegers Laravel-MongoDB package into my Laravel 4.2 project, and have a one problem. Maybe can help me. I cann't use DB::raw in select or get method. I need to change name of select column and add columns into one column, but Laravel return me an error. I try to do something like this:

$arr = StudentMark::join('students', 'students.id','=','student_marks.student_id')
        ->select(array('student_marks.id',DB::raw('CONCAT(students.name, " ",
students.surname, " (", students.index,") ") AS student')))->get();

But Laravel return me an error:

{"error":{"type":"ErrorException","message":"Illegal offset type","file":".....vendor\\jenssegers\\mongodb\\src\\Jenssegers\\Mongodb\\Query\\Builder.php","line":240}}

Can anybody help me?


Solution

  • I use select with columns, and concating columns do in foreach of results and then return to client, and that solve me a problem. :)