I have an Eloquent model (Presenters) that has three columns: id
, first_name
and last_name
. What I want to do is populate the select opti
You've provided the answer, look at the PaulDM reply
Just adapt it, hope it works for you:
// your eloquent model ...
public static function listPresenters() {
$ret = [];
foreach (self::all() as $presenter) {
$ret[$presenter->id] = "{$presenter->first_name} {$presenter->last_name}";
}
return $ret;
}
// your eloquent model ...
Presenter::select('id', DB::raw('CONCAT(first_name, " ", last_name) AS full_name'))->lists('full_name', 'id');