<?php

namespace Modules\Admin\Http\Controllers;

use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use Modules\Admin\Services\MenusService;

class AdminController extends Controller
{
    public function __construct()
    {

    }

    /**
     * Display a listing of the resource.
     * @return Renderable
     */
    public function index(Request $request)
    {
        $user = Auth::guard('web')->user();

        // 获取并共享可见菜单信息
        $menus = new MenusService();
        $menus = $menus->getMenusList(1);
//        if (!$request->user()->hasRole('superAdmin')) {
//            $menus = $this->filterMenu($menus, $request->user()->getAllPermissions()->pluck('name')->all());
//        }

        $data = [
            'user'  => $user,
            'menus' => $menus,
        ];

        return view('admin::index', $data);
    }

    public function welcomeView()
    {

    }
}
