I have two tables in a database, package and categories.
package has a field category_id that contains data in this form ["1","11"] and shows categories data in the form of a checkbox.
Now, I want all the data from package where category_id equal to categories id.
Here's my code :
public function archive_packages(Request $request, $slug){
$title='Archive Packages';
$para='';
$slugs='archive-packages';
$categoryRow = Category::where('slug',$slug)->first();
$categoryID = $categoryRow->id;
$package = Packages::whereRaw('JSON_CONTAINS(category_id, \'["11"]\')')->get();
dd($package);
return view('pages.archive-packages',compact('title','para','slugs','package'));
}
I'm getting the following error :
SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION
pre.JSON_CONTAINS does not exist (SQL: select * from `packages` where
JSON_CONTAINS(category_id, '["11"]'))