<?php
namespace App\Http\Controllers\Card;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Throwable;
use Exception;
use Carbon\Carbon;
use Illuminate\Validation\Rule;
use App\Models\User;
use App\Services\UtilService;

class HomeController extends Controller
{
    private $time;

    public function __construct()
    {
        $this->time = Carbon::now()->format('Y-m-d H:i:s');
    }

    /**
     * 生涯明信片首页
     * @date 2021/05/31
     * @author live
     */
    public function getHome(Request $request)
    {
        $isWx = UtilService::getIsWx($_SERVER['HTTP_USER_AGENT']);
        if(!$isWx) return redirect(route('wxIndex'));
        $data = [];
        if($request->session()->get('uid')){
            $userId = $request->session()->get('uid');
            $data['isLogin'] = 1;
            $user = User::where('uid',$userId)->select('uid','account')->first();
            $data['userName'] = $user->account ?? '';
        }else{
            $data['userName'] = '';
            $data['isLogin'] = 0;
        }

        return view('card.index', $data);
    }


}