<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
    public function map()
    {
        $this->mapAdminRoutes();
        $this->mapApiRoutes();
        $this->mapPublicRoutes();
    }

    /**
     * @return $this
     */
    protected function mapAdminRoutes()
    {
    	$adminDomain = env('DOMAIN_ADMIN');

		Route::domain($adminDomain)
			->middleware('web')
			->group(base_path('routes/routes_admin.php'));

        return $this;
    }

	/**
	 * Define the "api" routes for the application.
	 *
	 * These routes are typically stateless.
	 *
	 * @return void
	 */
	protected function mapApiRoutes()
	{
		$apiDomain = env('DOMAIN_API');

        Route::domain($apiDomain)
            ->middleware('api')
            ->group(base_path('routes/routes_api_v1.php'));

        Route::domain($apiDomain)
            ->middleware('api')
            ->group(base_path('routes/routes_api_v2.php'));

        Route::domain($apiDomain)
            ->middleware('api')
            ->group(base_path('routes/routes_api_v3.php'));

        Route::domain($apiDomain)
            ->middleware('api')
            ->group(base_path('routes/routes_api_v4.php'));

        Route::domain($apiDomain)
            ->middleware('api')
            ->group(base_path('routes/routes_api_tools.php'));
	}

    protected function mapPublicRoutes() {
        $publicDomain = env('DOMAIN_PUBLIC');

        Route::domain($publicDomain)
            ->middleware('web')
            ->group(base_path('routes/routes_public.php'));

        return $this;
    }
}
