<?php

namespace Portal\Overide;

use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use App\Enums\Permission;
use DB;

/**
 * Class PackageServiceProvider
 *
 * @see http://laravel.com/docs/master/packages#service-providers
 * @see http://laravel.com/docs/master/providers
 */
class ServiceProvider extends BaseServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @see http://laravel.com/docs/master/providers#deferred-providers
     * @var bool
     */
    protected $defer = false;

   /**
     * Register the service provider.
     *
     * @see http://laravel.com/docs/master/providers#the-register-method
     * @return void
     */
    protected $listen = [
        
        // \Workbench\Site\Events\EmailEvent::class => [
        //     \Workbench\Site\Handlers\Events\SentEmail::class
        // ],
    ];


    public function register()
    {
        
    }

    /**
     * Application is booting
     *
     * @see http://laravel.com/docs/master/providers#the-boot-method
     * @return void
     */
    public function boot()
    {
        $this->loadRoutesFrom(__DIR__.'/../routes/web.php');
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'overide');
        $this->menu();
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');

        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'overide');

    }

    protected function menu()
    {

        app('laravolt.menu.sidebar')->register(function (\Lavary\Menu\Builder $menus) 
        {

            $menu = $menus->add(__('Pengurusan Sistem'))->data('icon', 'align justify');
            $menu->add(__('User Management'), route('overide::overide.user'))
                 ->data('icon', 'circle')
                 ->active('users/*')
                 ->data('permission', Permission::MANAGE_USER);
            $menu->add(__('Roles Management'), route('overide::roles.index'))
                 ->data('icon', 'circle')
                 ->active('users/*')
                 ->data('permission', Permission::MANAGE_ROLE);

        });
       
    }
}