Support the ongoing development of →
Eloquent Blade Forms
Last updated 7 months ago.

Basic PHP I guess ?

    foreach($agents as $agent)
        $agents[$agent->index] = $agent->first_name." ".$agent->last_name;


Thanks zaalbarxx

$agents = Agent::lists($value, $key);

// view
{{ Form::select('agent_id', $agents) }}

Not quite what pogachar said. If you already have a collection, just do the following:

{{ Form::select('agent_id', $agents->lists('id', 'first_name');

Or, if you need the full name - write a getter on the model that retrieves them both as name(), then you can use name as the last argument in the lists() call.


Sign in to participate in this thread!

Full Stack Europe

Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 - All rights reserved.