How to handle response

Posted 4 years ago by maarten


I did some refactoring on a very muddy controller. I implemented a few repositories and now make use of the Laracast Validation package. That helped a lot. I am quite new to PHP / Laravel but i want to know how you guys handle to following:

I have a route which i hit via regual HTTP Post request but also via AJAX calls. How do you handle the different returns. For example, in my store method when i call a create method on my repository i captured it in a Try Catch block. When it is successfull i check if it's a Ajax request, then i do A, when normal HTTP POST i do B.

I am wondering how you guys are handling this problem.

Thanks in advance.

Kind regards,


Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.