Can I use Service/Repo Pattern with inheritance? #51589
Replies: 2 comments 10 replies
-
The only thing I can think of is the table name that is derived from the classname. The only way to find out is to try out. But why not services or repository pattern? why is that stressful, and why are Helper classes not? Because in my book, Helper classes are just repository classes that happens to extend the model they are the repository of. And if you are going to create more than one Helper class per model, it's just a service that happens to extend the model they are a service for. |
Beta Was this translation helpful? Give feedback.
-
@marius-mcp In my php code, if |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Php supports multilevel inheritance, so can I inherit Service/Repo classes with Models.
for e.g.
class UserService extends User(model)
class PostRepo extends Post(model)
What's the problem with approach? Please Suggest.
If there's none should Laravel framework adapt this pattern by default?
Beta Was this translation helpful? Give feedback.
All reactions