Don't reinvent features that Laravel already has

For example, soft deletes

Joel Clermont
Joel Clermont
2024-01-11

I see a lot of different Laravel projects, and one consistent problem I see is application code that could be better leveraging a built-in feature of Laravel.

For example, I recently did a code review on a project that had an archived_at column on a bunch of different tables. And then throughout controllers and model scopes, there was a lot of code to decide whether "archived" records should be returned.

This sounds suspiciously like soft deletes to me, which is already baked into Eloquent.

Sometimes Laravel will add a feature in a new version, and it may not make sense to immediately rewrite your code to use it, but soft deletes have been around almost since the beginning.

Lean into the framework and use what it offers. You'll write less code and other Laravel devs joining your team will be able to understand your code faster.

Here to help,

Joel

P.S. Want us to do a code review on your Laravel app? Book a call and let's talk about it.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.