Level 47
What does this produce?
Setting::where('section', $section)->select('key', 'value')->pluck('value');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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?
Please or to participate in this conversation.