• Laravel,  Laravel tips

    [Laravel tips] How to redirect users to a specific URL/route when the validation fails

    If you are using Form Request to validate your forms before you persist them in the database, when the validation fails, the user is usually redirected back to the same page that initiated the request. For instance if you are on /new-article page, after you submit the article you are creating, the user will be redirected back automatically to this very same URL if the data she entered failed to pass the validation. This is the desired behavior in majority of the cases. Lately, I was working on a form where I needed to redirect the user back to another route. I was working on an application where we have…

  • Laravel

    Adding Tests to your Laravel CRUD Application: Where to Start?

    This is an excerpt from my upcoming ebook Laravel testing 101 Imagine you are working on a Laravel side-project or you just joined a team working on a Laravel application, and it currently doesn’t have a single test. You want to change that, and add tests to the application. If you find yourself in this situation, you might not even know where to start. “Should I unit test everything? Should I just test the most critical parts of the application?” You might even find yourself asking “Why do I need tests in the first place?” I am writing an ebook to answer all these questions for you, and this is…