Laravel automatically checks for errors in the session data and so, an $errors variable is actually always available on all your views. If you want to display a modal when there are any errors present, you can try something like this:
Sometimes, when a modal appears you donot want to be hidden if you clicked outside it in the gray area around it in the whole page. to prevent that behavoir, Use the following small code to prevent all modals from this action: