Support the ongoing development of →
posted 9 years ago
Last updated 1 year ago.

You could put the logic in a (before) filter that does the database check, then redirects to your database-free controller.

It does depend, however, on whether you're checking if the database exists, or a table within a database exists. The former may be trickier, given that you'll get a database error trying to connect to the non-existent database.

You could always catch Laravel's database exception and perform your redirect on that.


Hi deringer

Adding an App:error catch in global.php looks like a suitable method. But using the following code does not work as per this thread, so I have asked the question why on there:

App::error(function(QueryException $exception, $code)
	// My logic here;
Last updated 9 years ago.

This works, so I will try this, thanks a lot for the help...

App::error(function (\Illuminate\Database\QueryException $e) {

   // Logic here

Yes, you need to use the full namespaced class name :)


Sign in to participate in this thread!


Your banner here too?

amityweb amityweb Joined 8 Feb 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.