<?php

namespace Rvsitebuilder\Queuesharedhost;

use Illuminate\Support\ServiceProvider;

class QueuesharedhostServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Boot the application events.
     */
    public function boot()
    {
        $this->registerConfig();

        $this->bootRoute();
        $this->bootTranslations();
        $this->bootViews();

        $this->defineMigrate();
        $this->defineVendorPublish();
    }

    /**
     * Register the service provider.
     */
    public function register()
    {
    }

    public function defineMigrate()
    {
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
    }

    /**
     * Boot Route.
     */
    public function bootRoute()
    {
        //TODO ใช้ cach route
        //$this->loadRoutesFrom( __DIR__.'/../routes', 'core');

        include_route_files(__DIR__.'/../routes');
    }

    /**
     * boot PublishAsset.
     */
    public function defineVendorPublish()
    {
        $this->publishes([__DIR__.'/../public' => public_path('vendor/rvsitebuilder/queuesharedhost')], 'public');
    }

    /**
     * Register views.
     */
    public function bootViews()
    {
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'queuesharedhost');
    }

    /**
     * Register translations.
     */
    public function bootTranslations()
    {
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'queuesharedhost');
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return [];
    }

    /**
     * Register config.
     */
    protected function registerConfig()
    {
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'queuesharedhost');
    }
}
