You can pass an array to the get()
method:
$licence_entraineur = Licencies::where(['structure_id' => Auth::user()->structure->id])
->where('type_licence_id', '1')
->get(['lb_nom', 'num_licence', 'id']);
Or use the select()
method:
$licence_entraineur = Licencies::select('lb_nom', 'num_licence', 'id')
->where(['structure_id' => Auth::user()->structure->id])
->where('type_licence_id', '1')
->get();
If you want to get pluck()
like array without keys, you can use the map()
method on a collection:
$licence_entraineur->map(function($i) {
return array_values((array)$i);
});
UPDATE
In the comments you've said you want to get mixed result, so use this code (works in 5.4, doesn't work in 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->num_licence.' - '.$i->lb_prenom];
});
Also, you could use an accessor here. Something like:
public function getTitleAttribute($value)
{
return $this->lb_nom.' - '.$this->num_licence.' - '.$this->lb_prenom;
}
And use it as ->pluck('title', 'id')