dimanche 30 octobre 2016

How to merge values of collection using pluck function?

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
    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2eIJq6N
via IFTTT

Aucun commentaire:

Enregistrer un commentaire