<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use PDOException;
use RedisException;
use Illuminate\Support\Facades\Redis;
use App\Http\Controllers\Controller;

class CheckController extends Controller
{
    public function getCheckDB()
    {
        $dbNames = ['mysql' => '用户中心数据库库','wx_mysql'=>'明信片库'];
        foreach ($dbNames as $key => $val) {
            try {
                DB::connection($key)->getPdo();
            } catch (PDOException $e) {
                return response('阿拉德明信片(uc_card):' . $val . '连接失败(' . $key . ')<br>' . $e->getMessage(), 500);
            }
        }

        try {
            Redis::connection('default');
        }catch(RedisException $e) {
            return response('阿拉德明信片(uc_card):redis连接失败(default)<br>' . $e->getMessage(), 500);
        }

        return response('OK');
    }
}