Returning external Array when taking data with Laravel

0

I have a column called clube and in a row it has the following {"clube":["Santos"]} , using that form for the data

$clubes = Socios::where('socio', $socio)->select('clube')->get();

It returns me this way [{"clube":"{"clube":["Santos"]}"}] , with an external array called clube , how can I return only what is inside the field in the database ??

    
asked by anonymous 12.08.2017 / 00:08

1 answer

1

Try to use laravel's method pluck , it would look something like this :

$clubes = Socios::where('socio', $socio)->pluck('clube');

If you want to array just add toArray () :

$clubes = Socios::where('socio', $socio)->pluck('clube')->toArray();
    
12.08.2017 / 00:23