laravel - Select Box Blade -
i try remove ids select box display name , surname , licence number licence object
here controller :
$licence_entraineur = licencies::select('lb_nom', 'num_licence', 'lb_prenom', 'id') ->where(['structure_id' => auth::user()->structure->id]) ->where('type_licence_id' , '1') ->get() ->map(function($i) { return [$i->lb_nom.' - '.$i->lb_prenom.' - n°'.$i->num_licence]; });
here blade view :
{!! form::select('licence_entraineur_id', $licence_entraineur , null, ['class' => 'form-control select2', 'placeholder' => 'selectionnez un entraineur']) !!}
everything works when go view , make dropdown of select box , values display :
0 mourareau - mathieu - 17085696
1 antoine - george - 17209669
2 aurore - alonso - 17856965
i remove 0 , 1 , 2 , ... numbers view
someone know how achieve ? lot in advance
in laravel 5.4 can use mapwithkeys()
. i've tested , works in 5.4 (in 5.3 helper has bug, it's not working):
$licence_entraineur = licencies::select('lb_nom', 'num_licence', 'lb_prenom', 'id') ->where(['structure_id' => auth::user()->structure->id]) ->where('type_licence_id' , '1') ->get() ->mapwithkeys(function($i) { return [$i->id => $i->lb_nom.' - '.$i->lb_prenom.' - n°'.$i->num_licence]; });
Comments
Post a Comment