Tuesday, April 11, 2017

how to get integer back using pluck and not an array?

I have this

Model::where('menu_id', 'core.extensions')->pluck('id')

and it returns an array back, so I have to do this

Model::where('menu_id', 'core.extensions')->pluck('id')[0]);

to get the integer id I want and instert it directly. How can I get id back and avoid using [0] since it does not look elegant to me.



via maxit

Advertisement