Laravel use of concat with pluck method
Try changing the eloquent query to:
$ProjectManagers = Employees::select(
DB::raw("CONCAT(first_name,' ',last_name) AS name"),'id')
->where('designation', 1)
->pluck('name', 'id');
if your column is nullable then you should try this
convert the NULL
values with empty string by COALESCE
$ProjectManagers = Employees::select(
DB::raw("CONCAT(COALESCE(`first_name`,''),' ',COALESCE(`last_name`,'')) AS name"),'id')
->where('designation', 1)
->pluck('name', 'id')
->toArray();
The most elegant solution is to create an accessor.
Open your Employees class (model) and add an accessor function:
public function getFullNameAttribute()
{
return $this->first_name . ' ' . $this->last_name;
}
After that, just simply use:
$ProjectManagers = Employees::where('designation', 1)->get()->pluck('full_name', 'id');