how do I mount a select with two fields using colletivehtml in laravel 5.5?

1

Good afternoon.

I use laravel 5.5 and for forms I use laravelcollective. I mount a select this way: $locals = Local::get()->pluck('codigolocal', 'id'); and the result is a select with value = id and description equal to the code.

My problem is that I need to show besides the code, also the description: Something like $locals = Local::get()->pluck(['codigolocal','descricaolocal'], 'id');

Can you do this?

Thank you.

    
asked by anonymous 06.12.2018 / 15:37

1 answer

1

Do the MySQL CONCAT command to join the fields and with the selectRaw method of Builder Eloquent to write a select equal to this:

Local::selectRaw("id‚CONCAT(codigolocal,' ',descricaolocal) as n")->pluck('n','id');

Other examples:

References:

06.12.2018 / 16:13