I am creating Validation service witch throws ValidationException if error ocured. That works fine, like it should, but got to the point where i need different exception outcomes depending on wather it responds to an ajax request or not.
Now i am checking in exception handler weather it is ajax request or not and return different responses.
I am creating service for validation to separate concerns, so validation exception shouldn't care about how data should be returned. So my current solution does not fallow separation of concerns pattern.
I was thinking of creating some Response service witch will be called from exception handler and will decade what format to return data. It could then be used for all sorts of different response/exception handling?
So i was wonderig what woulbe the best way for this. Mybe you have some ideas.
Thanks.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community