<?php

namespace Onestartup\Landings;

use Illuminate\Support\ServiceProvider;

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

        $this->loadViewsFrom(__DIR__.'/views', 'landings');
        
        if (is_dir(base_path() . '/resources/views/vendor/onestartup/landings/landing')) {
            $this->loadViewsFrom(base_path() . '/resources/views/vendor/onestartup/landings/landing', 'landing-public');
        }else{
            $this->loadViewsFrom(__DIR__.'/views/public', 'landing-public');
        }

        $this->publishes([
            __DIR__.'/assets' => public_path('assets'),
        ], 'public');

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

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

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