Example #1
0
Route::matched(function ($route, $request) {
    $isInstalling = false;
    $config = app('siteConfig');
    //If is install route, skip config check
    if ($route->getName() == Config::get('app-installer::routeName')) {
        $isInstalling = true;
    }
    if (!Config::get('database') && !$isInstalling) {
        die(Response::configurationError("Seems like you are starting up! Go on. Install it! Refer to documentation for instructions.", "Installation not completed"));
    }
    //If config is empty and if the user is not running the installer, Show error
    if (!$config && !$isInstalling) {
        if (!DB::connection()) {
            return Response::configurationError("Oops! The database cant be read!", "Database Connection error");
        } else {
            return Response::configurationError("Oops! The database is not configured properly!", "Database Configuration error");
        }
    }
});
App::before(function ($request) {
    //dd($request->getPathInfo() == route(Config::get('app-installer::routeName'), [], false));
    App::singleton('siteConfig', function () {
        //Loading config
        $config = array(0);
        try {
            $configRows = SiteConfig::all();
        } catch (Exception $e) {
            //Config cant be read! DB cant be accessed or Installation not completed
            //return Response::configurationError("Please complete installation and check again.", "Installation incomplete!");
            return false;
        }