<?php
namespace App\Domains\File\Providers;

use Illuminate\Support\ServiceProvider;
use App\Domains\File\Providers\MiddlewareProvider;
use App\Domains\File\Providers\RouteServiceProvider;

class FileServiceProvider extends ServiceProvider
{
    /**
     * 引导启动任何应用程序服务
     *
     * php artisan make:migration --path=app/Domains/File/Database/migrations
     *
     * @return void
     */
    public function boot()
    {
        $this->loadMigrationsFrom([realpath(__DIR__ . '/../Database/migrations')]);

        app('events')->listen(\App\Events\FileApplyEvent::class, \App\Domains\File\Listeners\FileApplyListener::class);
        app('events')->listen(\App\Events\FileDetachEvent::class, \App\Domains\File\Listeners\FileDetachListener::class);
        app('events')->listen(\App\Events\FileUploadEvent::class, \App\Domains\File\Listeners\FileUploadListener::class);
    }

    /**
     * 注册一个服务提供者
     *
     * @return void
     */
    public function register()
    {
        $this->app->register(RouteServiceProvider::class);
        $this->app->register(MiddlewareServiceProvider::class);
    }
}
