<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\WechatInfo;

class WechatInfoController extends Controller
{

    /**
     * 获取微信信息
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    function get(Request $request) {
        $wechat_id = $request->input("openid");
        if($wechat_id) {
            $info = WechatInfo::where("openid", $wechat_id)->first();

            return Response()->json([
                "status" => 0,
                "data" => $info
            ]);
        }
    }


    /**
     * 获取所有微信信息
     * @param Request $request
     * @return mixed
     */
    public function list(Request $request)
    {
        return WechatInfo::paginate(20);
    }
}
