Laravel custom errors

When you develop Laravel application you may need to send custom error messages from Laravel Controller to the Laravel View.

So you can have the following code inside the controller

Here I am redirect to the same route
But if you want to redirect to a view you can use the following code

Now inside your view you can add the following code to show the error messages you received from the controller.