MultiStepFormsServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Infinitypaul\MultiStep;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
use Infinitypaul\MultiStep\Controller\MultiStepManager;
8
use Infinitypaul\MultiStep\Routing\PendingMultiStepRegister;
9
10
class MultiStepFormsServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application services.
14
     */
15
    public function boot()
16
    {
17
18
        //$this->loadRoutesFrom(__DIR__.'/routes.php');
19
20
        Route::macro('multistep', function ($uri, $controller) {
21
            return new  PendingMultiStepRegister($uri, $controller);
22
        });
23
24
        if ($this->app->runningInConsole()) {
25
            $this->publishes([
26
                __DIR__.'/../config/steps.php' => config_path('steps.php'),
27
            ], 'config');
28
29
            if (! class_exists('CreateMultiStepsTable')) {
30
                $this->publishes([
31
                    __DIR__.'/../database/migrations/create_multisteps_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_multisteps_table.php'),
32
                ], 'migrations');
33
            }
34
35
            // Registering package commands.
36
            // $this->commands([]);
37
        }
38
    }
39
40
    /**
41
     * Register the application services.
42
     */
43
    public function register()
44
    {
45
        // Automatically apply the package configuration
46
        $this->mergeConfigFrom(__DIR__.'/../config/steps.php', 'steps');
47
48
        // Register the main class to use with the facade
49
        $this->app->singleton('laravel-multistep-forms', function ($app) {
50
            return new MultiStepManager($app);
51
        });
52
    }
53
}
54