<?php

namespace Portal\Overtime;

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


/**
 * Class PackageServiceProvider
 *
 * @package Portal\Ecuti
 * @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;


    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        
        \Portal\Overtime\Events\NotifyEmail::class => [
            \Portal\Overtime\Handlers\Events\SentEmail::class
        ],
    ];



    /**
     * Register the service provider.
     *
     * @see http://laravel.com/docs/master/providers#the-register-method
     * @return void
     */
    public function register()
    {
        // $this->app->bind('staff', \Portal\Ecuti\Data\Repo\StaffRepo::class);
    }

    /**
     * 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', 'overtime');
        $this->menu();
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');

        //add old laravolt view directive
        $this->loadViewsFrom(realpath(__DIR__ . '/../resources/views'), 'ui');

        // allow views to be published to the storage directory
        $this->publishes(
            [realpath(__DIR__ . '/../resources/views') => base_path('resources/views/vendor/ui')],
            'views'
          );

    }

    protected function menu()
    {

     app('laravolt.menu.sidebar')->register(function (\Lavary\Menu\Builder $menus) 
     {
          $menu = $menus->add(__('Tuntutan Lebih Masa'))->data('icon', 'align justify');
          $menu->add(__('Senarai Permohonan '), url('/overtime/index'))
               ->data('icon', 'home')
               ->active('overtime/*');
               // ->data('permission', Permission::PROJECT_MANAGER);

     });

    }
}