Hi. I think about two different ways, which seems to do the same. The problem. In my current project i have both of the two and I think about to refactor to only have actions or repositories.
First is the repository pattern. I saw it in the past, when I used cartalyst platform, which is a laravel cms with extensions.
Second are Actions, which came for example with fortify.
The repository pattern is to make database stuff easier. For example delete. In the class i had a method called delete($id), which checked with gate if user is able to do this, send some tracking stuff, ...
Now i see, that actions seems to do the same... The make reusable code. Is this both the same and only other ways, or am I totally wrong?
to me, repository pattern allows you to abstract away the database storage layer, whereas actions are more about encapsulating pieces of business logic into reusable components. An action might involve more than one model so it can be seen as a level above repository or eloquent
I never use repository pattern as the overlap to what eloquent offers is too great
That was my first idea when we started the project. Now i thought about it and see in app/Actions/Fortify/CreateNewUser.php that there is also created a user with User::create. So I think about instead having a repository with (findById, findBySlug, create, delete, deleteAll) I use actions and do stuff there. All the find stuff could be done maybe in the model and real actions like create or delete could be done as action... Mhhh. I think this all is more a thing, what everyone has do decide with his team how to do it. I will talk to the other. Thx @snapey
PS: Not sure if you edited the post, but I did not see the "I never use repository pattern as the overlap to what eloquent offers is too great". Then it is clear for me. I think we will go with actions and eloquent and I dont use repositories anymore.
@Snapey :) thx for the link https://twitter.com/kniklas/status/1519270161429286914 ... Yes. Eloquent really does the most things. We just decided to use actions and models an no repository anymore. Actions will be called in controllers like "CreateUser" this will do all tracking stuff, send mail to user and create user via model in database.