<?php

namespace app\controller;

use support\Request;

use App\Utils\ApiResponse;

class IndexController
{
    public function index(Request $request)
    {
        static $readme;
        if (!$readme) {
            $readme = file_get_contents(base_path('README.md'));
        }
        return $readme;
    }

    public function view(Request $request)
    {
        return view('index/view', ['name' => 'webman']);
    }

    public function json(Request $request)
    {
        // return json(['code' => 0, 'msg' => 'ok']);
        $users = [
            ['id' => 1, 'name' => '张三'],
            ['id' => 2, 'name' => '李四'],
        ];
        return ApiResponse::success($users);
    }

}
