JSON Search in laravel eloquent

In Laravel 5.6 and higher you can use whereJsonContains method:

Package::whereJsonContains('destinations',["Goa"])->get();

But not all DB support it: https://laravel.com/docs/5.6/queries#json-where-clauses


Probably forced to use a partially raw query like:

use DB; (top of file definition)

DB::table('packages')->whereRaw('json_contains(destinations, \'["Goa"]\')')->get();

And if you have a model:

Package::whereRaw('json_contains(destinations, \'["' . $keyword . '"]\')')->get();

assuming your query above works in SQL.