How to handle response

Posted 4 years ago by maarten

Hi,

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,

Maarten.

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.