Courses

Eloquent: The Expert Level (Laravel 9)

Local and Global Scopes for Repeating Conditions

Previous: Brackets Between "and" / "or" Conditions
avatar

Hello, how to handle local scope when there are NO records? the builder returns an object, don't return null or empty collection for one on the controller/component side do some if condition to handle cases when there is or isn't records....currently in my component in the livewire mount I use a local scope that when there are records it works perfect but when there aren't it it crashes for that builder object (when no records).

avatar

Very hard to answer without a specific code example and cases when it crashes or not. Needs debugging.

avatar
You can use Markdown
avatar
You can use Markdown