I use the pluck()
function to get output collection with key, value:
$work_types = Work::orderBy('name')->get()->pluck('name', 'id');
Output is:
{
0 => "Name1",
1 => "Name2",
2 => "Name3
}
How can I merge value name
with value id
that to get the following object:
{
0 => "0 -Name1",
1 => "1 - Name2",
2 => "2 - Name3
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire