how to use GROUP_CONCAT in laravel -
$assignment = assignment::find(crypt::decrypt($id)); $assignment_details = $assignment->raw_plan()->groupby('flag')->get();
i want following result of query in laravel
select group_concat(name) 'names' `raw_plans` `assignment_id` = 1 group by`flag`
please suggest me how use group_concat in laravel
you can use relations query builder fetch results as:
$assignment_details = $assignment->raw_plan() ->select(db::raw('group_concat(name) names')) ->where('assignment_id', 1) ->groupby('flag') ->get();
update
use table_name.*
in select fields.
$assignment_details = $assignment->raw_plan() ->select('raw_plans.*', db::raw('group_concat(name) names')) ->where('assignment_id', 1) ->groupby('flag') ->get();
Comments
Post a Comment