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"}]



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3t4Pb11
via IFTTT

Aucun commentaire:

Enregistrer un commentaire