Level 60
What is $slice? and what are your trying to do here? What is $item . '_id'?
$query = $query->whereNull($item . '_id');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I keep having to add little loops to my eloquent queries, it's not the end of the world, it just adds a few extra lines where I might be missing a potential callback function somewhere that might make things a bit cleaner:
$query = Place::where($place->type_1 . '_id', $place->id)
->whereType_1($child_type)
->limit(1);
// Here is where I'm talking about
foreach ($slice as $item) {
$query = $query->whereNull($item . '_id');
}
$result = $query->get()->first();
Is there any looping functionality in Eloquent?
Please or to participate in this conversation.