<?php
/**
 * Created by PhpStorm.
 * User: ywl
 * Date: 2017/4/14
 * Time: 10:56
 */

namespace App\User\Providers;


use App\Providers\EventServiceProvider;
use App\User\Facades\AttachmentFacade;
use App\User\Facades\SysAdminUserFacade;
use App\User\Facades\SysLogFacade;
use App\User\Facades\SysMenuFuncAuthFacade;
use App\User\Facades\SysMenuFuncFacade;
use App\User\Facades\SysRoleFacade;
use App\User\Facades\UserFacade;
use App\User\Models\AttachmentModel;
use App\User\Models\SysAdminUserModel;
use App\User\Models\SysLogModel;
use App\User\Models\SysMenuFuncAuthModel;
use App\User\Models\SysMenuFuncModel;
use App\User\Models\SysRoleModel;
use App\User\Models\UserModel;
use App\User\Services\AttachmentService;
use App\User\Services\SysAdminUserService;
use App\User\Services\SysLogService;
use App\User\Services\SysMenuFuncAuthService;
use App\User\Services\SysMenuFuncService;
use App\User\Services\SysRoleService;
use App\User\Services\UserService;
//EloquentUserProvider
class UserProvider extends EventServiceProvider
{

    /**
     * 注册绑定门面
     */
    public function register()
    {
        $this->registerAdminUser();
        $this->registerSysMenuFuncAuth();
        $this->registerSysRole();
        $this->registerSysMenuFunc();
        $this->registerAttachment();
        $this->registerSysLog();
    }


    /**
     * 注册adminUser
     */
    protected function registerAdminUser()
    {
        $this->app->bind(SysAdminUserService::class, function () {
            return new SysAdminUserService(new SysAdminUserModel());
        });
        $this->app->bind(SysAdminUserFacade::class, function () {
            return app()->make(SysAdminUserService::class);
        });
    }

    /**
     * 注册SysMenuFuncAuth
     */
    protected function registerSysMenuFuncAuth()
    {
        $this->app->bind(SysMenuFuncAuthService::class, function () {
            return new SysMenuFuncAuthService(new SysMenuFuncAuthModel());
        });
        $this->app->bind(SysMenuFuncAuthFacade::class, function () {
            return app()->make(SysMenuFuncAuthService::class);
        });
    }

    /**
     * 注册SysRole
     */
    protected function registerSysRole()
    {
        $this->app->bind(SysRoleService::class, function () {
            return new SysRoleService(new SysRoleModel());
        });
        $this->app->bind(SysRoleFacade::class, function () {
            return app()->make(SysRoleService::class);
        });
    }

    /**SysMenuFuncFacade
     * 注册SysMenuFunc
     */
    protected function registerSysMenuFunc()
    {
        $this->app->bind(SysMenuFuncService::class, function () {
            return new SysMenuFuncService(new SysMenuFuncModel());
        });
        $this->app->bind(SysMenuFuncFacade::class, function () {
            return app()->make(SysMenuFuncService::class);
        });
    }



    //注册附件
    protected function registerAttachment(){
        //公司信息
        $this->app->bind(AttachmentService::class, function () {
            return new AttachmentService(new AttachmentModel());
        });
        $this->app->bind(AttachmentFacade::class, function () {
            return app()->make(AttachmentService::class);
        });
    }

    /**
     * 注册系统日志
     */
    protected function registerSysLog()
    {
        $this->app->bind(SysLogService::class, function () {
            return new SysLogService(new SysLogModel());
        });
        $this->app->bind(SysLogFacade::class, function () {
            return app()->make(SysLogService::class);
        });
    }
}
