michal michal - 4 months ago 28
JSON Question

Laravel json convert to array only number PHP

I have code:

return $getId = Permission::select('id')->get();

This code returned me:


I want to query returned the records in the form of:


How can I do this? I tried to use
, but it's not work I also tried to use a foreach loop, but the result was the same. I'm doing this because I want to compare the two tables using
, but still I have error:

array_diff(): Argument #1 is not an array

Argument 1
is variable


You want to use pluck() and toArray() methods:

return $getId = Permission::pluck('id')->toArray();