Laravel tip:
If you use `whereHas()` and then eager load the same relationship with the same condition, you might be duplicating logic.
`withWhereHas()` keeps it cleaner.
Punyapal Shah ⚡
@MrPunyapal
Laravel Artisan | Open Source Contributor | Speaker | Core Team @Pinkary 🤌 Creator of @LaravelArtisans 🙌
2K
Posts
19K Views
Everyone has the problems, some find solution from others and some create solution for others.
Laravel tip:
If you update records while chunking them, be careful with `chunk()`.
Because `chunk()` uses offset pagination, changing the result set during processing can make you skip rows.
Use `chunkById()` when the records can change while processing.
Laravel tip:
Validating the request and then saving `$request->all()` is like checking IDs at the door…
then letting everyone inside anyway.
Use the validated data, not the full request.