vendredi 30 avril 2021

How to return values in array of json using laravel query?

$search='m';
$data = Product::select("product_name")
        ->where('product_name','LIKE', '%' . $search . '%')
        ->get();
    
 return response()->json($data);

It returns

[{"product_name":"MyProduct"},{"product_name":"MAC"}] .....

But I want [{"MyProduct"},{"MAC"}]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire