(bool)$system_health, 'extensions' => self::extensions(), 'php_version' => phpversion(), 'min_php_version' => self::$php_version, //'dbs' => self::dbCheck(), //'mail' => self::testMailServer(), 'env_writable' => self::checkEnvWritable(), ]; } private static function extensions() :array { $loaded_extensions = []; foreach (self::$extensions as $extension) { $loaded_extensions[] = [$extension => extension_loaded($extension)]; } return $loaded_extensions; } public static function dbCheck($request = null): array { $result = ['success' => false]; if ($request && $request instanceof CheckDatabaseRequest) { config(['database.connections.db-ninja-01.host'=> $request->input('host')]); config(['database.connections.db-ninja-01.database'=> $request->input('database')]); config(['database.connections.db-ninja-01.username'=> $request->input('username')]); config(['database.connections.db-ninja-01.password'=> $request->input('password')]); config(['database.default' => 'db-ninja-01']); DB::purge('db-ninja-01'); } if (! config('ninja.db.multi_db_enabled')) { try { $pdo = DB::connection()->getPdo(); $result[] = [ DB::connection()->getDatabaseName() => true ]; $result['success'] = true; } catch (\Exception $e) { $result[] = [ config('database.connections.' . config('database.default') . '.database') => false ]; $result['success'] = false; } } else { foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); try { $pdo = DB::connection()->getPdo(); $result[] = [ DB::connection()->getDatabaseName() => true ]; $result['success'] = true; } catch (\Exception $e) { $result[] = [ config('database.connections.' . config('database.default') . '.database') => false ]; $result['success'] = false; } } } return $result; } private static function checkDbConnection() { return DB::connection()->getPdo(); } public static function testMailServer($request = null) { if ($request && $request instanceof CheckMailRequest) { config(['mail.driver' => $request->input('driver')]); config(['mail.host' => $request->input('host')]); config(['mail.port' => $request->input('port')]); config(['mail.from.address' => $request->input('from_address')]); config(['mail.from.name' => $request->input('from_name')]); config(['mail.encryption' => $request->input('encryption')]); config(['mail.username' => $request->input('username')]); config(['mail.password' => $request->input('password')]); } try { Mail::to(config('mail.from.address')) ->send(new TestMailServer('Email Server Works!', config('mail.from.address'))); } catch (\Exception $e) { return $e->getMessage(); } if (count(Mail::failures()) > 0) { return Mail::failures(); } return []; } private static function checkEnvWritable() { return is_writable(base_path().'/.env'); //return @fopen(base_path().'/.env', 'w'); } }