I have an issue where I'm trying to match 2 arrays (Check if $_POST array has values that are contained in the database array)
- Array : ['79','80'] (this is stored inside my database)
- Array : ['78','79','80'] (this is a POST from checkbox's)
Here's a snippet of my code
$filter = Course::GetAllCourses()->where('for_sites',2)->orderBy("set_date","DESC");
// I've tried
if ($request->getParam('level')) {
$filter->where('groups',$request->getParam('level'));
}
// Also tried this resukt: nothing shows (no errors ) this works for a single value only though
foreach ($request->getParam('level') as $levels) {
if ($request->getParam('level')) {
$filter->where('groups','LIKE','%' . $levels . '%');
}
}
// Also tried this shows everything doesn't matter what kind of 'level ' I've posted
foreach ($request->getParam('level') as $levels) {
if ($request->getParam('level')) {
$filter->orWhere('groups','LIKE','%' . $levels . '%');
}
}
$db_course = $filter->distinct()->get();
So the end game is:
If i $_POST values of array ['78','79','80'] i want to get results that have ['78','79'] or all three values or even just 1 blue e.g. ['78'] is this even possible?