Laravel dedicated builder object

5/20/2019
ยท 1 min read

๐Ÿญ Want to thin out your @laravelphp models? You can relocate scopes to dedicated builder object.

Gain:
โœ… Thinner models
โœ… Click through in your editor
โœ… Static analysis (if that's ur bag)

Lose:
โŽ Having every co-located

Step 1: Make a custom builder

step1

Step 2: Return your dedicated builder from the newEloquentBuilder method on your model.

๐Ÿ“Œ Scopes on your model will continue to function, so you can progressively refactor if you need.

step2

Enjoy!

enjoy

From @timacdonald87.

You can find this page with theses search keywords:

/ model / scope / query /
Mathieu TUDISCO
Thanks for reading!
I'm Mathieu TUDISCO, a lead developer at Linkvalue .
You can find me anywhere with @mathieutu.
As a start you can follow me on Twitter or want to find out more about me or the blog.