Top Menu

Some time we need concat multiple fields with pluck function in laravel

Here we describe how use multiple columns in pluck function use of concat

public function get_course()
{
$course_type = $_GET['course_type'];
$courseArray = DB::table('courses')->where(['status' => 0, 'course_type' => $course_type])
->orderBy('name', 'asc')
->pluck(DB::raw('CONCAT(name," -->",duration_in_month, " Months") AS name'),'id');
return json_encode($courseArray);
}

About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Close