I have Laravel 6 code below displays the array with the object format. So I like to display instead of object-based array, just array as I have mentioned below.
$ins_affiliations = DB::table('ins_affiliations as af')
->select('af.id','af.name')
->where(['af.ins_category_id' => $ins_category_type[0]->category_id])
->get()->toArray();
my code shows
Array
(
[0] => stdClass Object
(
[id] => 12
[name] => NSDC
)
[1] => stdClass Object
(
[id] => 13
[name] => NCVT
)
[2] => stdClass Object
(
[id] => 14
[name] => AICTE
)
[3] => stdClass Object
(
[id] => 15
[name] => Others
)
)
what I need
Array
(
[12] => NSDC
[5] => NCVT
[8] => AICTE
[11] => Others
)
How can I achieve this?
pluck('name', 'id')insteadget()to execute your query