Select 盒子 Blade
Select Box Blade
我尝试从 select 框中删除显示许可证 Object
中的名称、姓氏和许可证号的 IDS
这里是我的控制器:
$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];
});
这是我的 blade 观点:
{!! Form::select('licence_entraineur_id', $licence_entraineur , null, ['class' => 'form-control select2', 'placeholder' => 'Selectionnez un Entraineur']) !!}
一切正常,但是当我进入我的视图并下拉 select 框时,值显示如下:
0
穆拉罗 - 马修 - 17085696
1
安托万 - 乔治 - 17209669
2
极光 - 阿隆索 - 17856965
我想从视图中删除 0 、 1 、 2 ……数字
有人知道如何实现吗?非常感谢
在 Laravel 5.4 中您可以使用 mapWithKeys()
。我刚刚测试过它在 5.4 中工作(在 5.3 中这个助手有一个错误,所以它不工作):
$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];
});
我尝试从 select 框中删除显示许可证 Object
中的名称、姓氏和许可证号的 IDS这里是我的控制器:
$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];
});
这是我的 blade 观点:
{!! Form::select('licence_entraineur_id', $licence_entraineur , null, ['class' => 'form-control select2', 'placeholder' => 'Selectionnez un Entraineur']) !!}
一切正常,但是当我进入我的视图并下拉 select 框时,值显示如下:
0 穆拉罗 - 马修 - 17085696
1 安托万 - 乔治 - 17209669
2 极光 - 阿隆索 - 17856965
我想从视图中删除 0 、 1 、 2 ……数字
有人知道如何实现吗?非常感谢
在 Laravel 5.4 中您可以使用 mapWithKeys()
。我刚刚测试过它在 5.4 中工作(在 5.3 中这个助手有一个错误,所以它不工作):
$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];
});