php - select data which has on json data in Laravel
one text
I have this JSON data on user table feild name 'pincodes': "["712401","712415"]"
and I have an order table: which contains 'pincodes' field on database.
I want data from order table whose pincode has on "["712401","712415"]"
public function orders()
{
$pincodes = Auth::user()->pin_codes;
$order_list = Order::whereJsonContains('pin_code',$pincodes)->get();
//dd($order_list);
return view('delivery.orders', compact('order_list'));
}
Source