php - Laravel - Populating Select List with Derived Values -


i have eloquent model (presenters) has 3 columns: id, first_name , last_name. want populate select options id value, , first_name . last_name displayed.

for instance, if had these presenters:

id, first_name, last_name 1, billy, bob 2, jose, cuervo 3, puff, magic dragon 

i want similar output:

<select name="presenters">     <option value="1">billy bob</option>     <option value="2">jose cuervo</option>     <option value="3">puff magic dragon</option> </select> 

i know if care last name or first name in select list, can this:

{{ form::select("presenters", presenter::lists("first_name", "id"), input::old("presenters"), array( "class" => "form-control" )) }} 

there many questions regarding populating select inputs models in laravel, although haven't found 1 yet shows how populate select input derived value shown in each of options rather single column.

can use lists method populate select element, or need populate own array of values / option texts?

presenter::select('id', db::raw('concat(first_name, " ", last_name) full_name'))->lists('full_name', 'id'); 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -