0

I have some trouble here. I use Backpack CRUD generator for my admin panel. In the database (categories column) I have a "parent_id" field which specify which is parent and children. The addFiled of CRUD has a type "select_from_array" which accept an array ( 'value'=>'name'). And I don't know how to make an array which something like that from the array I got from DB toArray(). Tks alot.

1 Answers1

1

In order to get an associative array of Product names, with the IDs as keys, you would do this:

Product::all()->keyBy('id')->pluck('name')->toArray()

Hope it helps.

tabacitu
  • 6,047
  • 1
  • 23
  • 37