<?php

namespace Sargilla\Canvas;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use Illuminate\Foundation\Console\PresetCommand;

class CanvasServiceProvider extends ServiceProvider
{
	/**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        if (!defined('CANVAS_PATH')) {
            define('CANVAS_PATH', realpath(__DIR__.'/../'));
        }
     
        // Registra Comandos x consola
        if ($this->app->runningInConsole()) {
            $this->commands([\Sargilla\Canvas\Console\InstallCanvas::class]);
        } 
    
    }
    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
       //	$this->publishConfig();
        $this->publishAssets();
        $this->presetCommand();
    }

    /**
     * Publica las config.
     */
    // protected function publishConfig()
    // {
    // 	$this->publishes([CANVAS_PATH.'/config/canvas.php' => config_path('canvas.php')],'paginas');
    // }
    
    /**
     * Publica Vue Componentes.
     */
    public function publishAssets()
    {
    	$this->publishes([
    		CANVAS_PATH.'/resources/canvas' => resource_path('canvas')
    	],'canvas');
    }
    protected function presetCommand()
    {
        PresetCommand::macro('canvas', function ($command) {
            CanvasPreset::install();
            $command->info('Preset establecido!');
        });
    }

}
