<?php

namespace Onestartup\CrmForms;

use Illuminate\Support\ServiceProvider;

class CrmFormsServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        include __DIR__.'/routes.php';
        $this->loadMigrationsFrom(__DIR__.'/migrations');


        if (is_dir(base_path() . '/resources/views/vendor/onestartup/crmforms')) {

            $this->loadViewsFrom(base_path() . '/resources/views/vendor/onestartup/crmforms', 'crmforms-public');
            $this->loadViewsFrom(__DIR__.'/views', 'crmforms');

        } else {
           
            $this->loadViewsFrom(__DIR__.'/views', 'crmforms');
            $this->loadViewsFrom(__DIR__.'/views/public', 'crmforms-public');
        }

        $this->publishes([
            __DIR__.'/assets' => public_path('assets'),
        ], 'public');
        
        $this->publishes([
            __DIR__.'/views/public' => resource_path('views/vendor/onestartup/crmforms'),
        ]);

        
        /*$this->publishes([
            __DIR__.'/config/crmforms.php' => config_path('crmforms.php'),
        ], 'config');*/



    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->make('Onestartup\CrmForms\Controller\CrmFormsController');
        $this->mergeConfigFrom( __DIR__.'/config/crmforms.php', 'crmforms');
    }
}