Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shez1983's avatar

repository/Services pattern

I would like to know how you use repository pattern? i know some packages mimic eloquents find/create etc. but what about complex things for example: get me this clients Order? do you do $userRepository->getUsersOrders() (or perhaps $orderRepository->getUsersOrders()).. and what about if you want to get an Orders Count.. do you use the same function but pass in a param called count? or do you create a new func called getUsersOrdersCount()...

*assume for this example its a complex query and user/order are not directly related..

or do you do something else?

I tend to do that but often get confused where to put the function like in my example..

Just trying to get opinions/suggestions etc

Edit: one thing i dont like about the packages is that you still do the same thing you do if you were using eloquent ie with(); or whereHas()...

0 likes
0 replies

Please or to participate in this conversation.