You can use the JSON where clauses.
$currentSupplierId = 3;
$orders = Order::whereJsonContains('supplier_ids', $currentSupplierId)->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello friends, how to use where query a in casted array field for EXAMPLE
protected $casts = [
'supplier_ids' => 'array',
];
// db table field data stored like thats
[1,2,3,4]
[1,3,5,7]
$currentSupplierId = 3;
$orders = Order::->where('supplier_ids', $currentSupplierId)->get();
** HOW TO DO THIS QUERY , THANKS FOR TIME
You can use the JSON where clauses.
$currentSupplierId = 3;
$orders = Order::whereJsonContains('supplier_ids', $currentSupplierId)->get();
Please or to participate in this conversation.