paint-brush
My Laravel Repository Pattern Solution (in only 30 lines of code)by@sjors-van-dongen
6,011 reads
6,011 reads

My Laravel Repository Pattern Solution (in only 30 lines of code)

by Sjors van Dongen4mSeptember 16th, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A 30 line script can finally provide a good solution for a repository pattern in Laravel apps. The problem is that you can’t use Eloquent functions on your repositories. A repository with the use of the Repository trait would look like this: $model-repositories-repository-referreditories. The solution was created by creating a simple piece of code which enables all the features of Elquent on your repository. This way you can use the repository pattern as a way to keep your models and your repositories clean!

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - My Laravel Repository Pattern Solution (in only 30 lines of code)
Sjors van Dongen HackerNoon profile picture
Sjors van Dongen

Sjors van Dongen

@sjors-van-dongen

L O A D I N G
. . . comments & more!

About Author

Sjors van Dongen HackerNoon profile picture
Sjors van Dongen@sjors-van-dongen

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite