Sunday, April 9, 2017

how to get key -> value order?

I have this code:

Setting::where('section', $section)->select('key', 'value')->pluck('value')->toArray();

it produces this:

  0 => "true"
  1 => "native"
  2 => "true"
  3 => "true"

I need this

 enable => "true"
 type => "native"
 must_be_registered => "true"
 allow_nested => "true"

how do I get that? I tried pluck('key', 'value') but that did not return all values from DB for some reason some were missing, this is what came out:

 array:3 [▼
      "true" => "allow_nested"
      "native" => "type"
 ]

it came out in value => key order and was missing keys and values

How can I get key => value?



via maxit

Advertisement