Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 2 years ago.
0

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.

0

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: http://laravel.io/forum/09-08-2014-how-to-create-custom-query-error-exception

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

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

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

   // Logic here
});
0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

amityweb amityweb Joined 8 Feb 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.