JSON Search in laravel eloquent

后端 未结 2 1213
遇见更好的自我
遇见更好的自我 2021-02-05 19:11

I am storing destinations field as json type in mysql

example column value [\"Goa\", \"Moonar\", \"Kochi\"]

I

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 19:50

    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

提交回复
热议问题