Yeah, an array seems to be the best option here. You can use the method whereIn to make this work
Course::whereIn('name', ['englsh 1', 'basic english 1'])->first();
Well, you get the idea ;)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to do an import of a school's courses and their teacher and students, the thing is these are auto generated reports and sometimes a course will have more than one name depending on the course plan, for example a general english 1 class can have a different name if you're studying engineering or nursing, could be english 1 and basic english 1.
This is the small method I'm using to get the relevant course
private function getCourse($name, $num)
{
$course = Course::where('name', $name)->where('num', $num)->first();
if (empty($course)) {
$course = new Course();
}
return $course;
}
How can I in the best way check for these different names? Should I put them in an array or what's my best choice?
Please or to participate in this conversation.