MrPunyapal
MrPunyapal

Punyapal Shah ⚡

Verified

@MrPunyapal

Laravel Artisan | Open Source Contributor | Speaker | Core Team @Pinkary 🤌 Creator of @LaravelArtisans 🙌
2K Posts 19K Views
  • No matching results...
  • Searching...

/ 255

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.
image

Everyone has the problems, some find solution from others and some create solution for others.

37

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.
image

54

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.
image

32