Sometimes we are dealing with JSON columns in our tables. We can easily select and update records on the bases of JSON values in any columns. For example, here in our leads table we have options column. We can select records on the bases of any child in that column in JSON form.
$verifiedLeads = DB::table( 'leads' )
->where( 'options->is_verified', '=',true )
->get();
We can also update any child in JSON column.
DB::table( 'leads' )->update( ['options->is_verified' => true ]);
When you are debugging a JSON column it helps to have somewhere to paste a blob and see it laid out properly, or to turn a CSV export into JSON before you write the seeder for it.
The Free Converter has free text, CSV and JSON tools that run in the browser with no install and no account. Handy in a second tab next to a Tinker session when you just want to eyeball the structure.
I hope now you can use JSON queries in Laravel query builder. It is very convenient and easy to use with great power. If you have any questions please leave a comment. We appreciate that. Enjoy learning.












