EventsServiceProvider   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 73
rs 10
wmc 11
lcom 1
cbo 2

9 Methods

Rating   Name   Duplication   Size   Complexity  
A loadCommands() 0 12 2
A defineApiRoutes() 0 3 1
A loadViews() 0 4 1
A loadMigrations() 0 4 1
A registerEloquentFactoriesFrom() 0 4 1
A register() 0 9 2
A boot() 0 8 1
A defineRoutes() 0 5 1
A defineWebRoutes() 0 3 1
1
<?php
2
3
namespace Acacha\Events\Providers;
4
5
use Acacha\Events\Console\Commands\CreateEventCommand;
6
use Acacha\Events\Console\Commands\DeleteEventCommand;
7
use Acacha\Events\Console\Commands\EditEventCommand;
8
use Acacha\Events\Console\Commands\Esborrar;
9
use Acacha\Events\Console\Commands\ListEventsCommand;
10
use Acacha\Events\Console\Commands\ShowEventCommand;
11
use Illuminate\Support\ServiceProvider;
12
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
13
14
/**
15
 * Class EventsServiceProvider.
16
 */
17
class EventsServiceProvider extends ServiceProvider
18
{
19
20
    public function register()
21
    {
22
        if (!defined('EVENTS_PATH')) {
23
            define('EVENTS_PATH', realpath(__DIR__.'/../../'));
24
        }
25
26
        $this->registerEloquentFactoriesFrom(EVENTS_PATH . '/database/factories');
27
28
    }
29
30
    public function boot()
31
    {
32
33
        $this->defineRoutes();
34
        $this->loadViews();
35
        $this->loadmigrations();
36
        $this->loadCommands();
37
    }
38
39
    /**
40
     * Load commands
41
     */
42
    protected function loadCommands()
43
    {
44
        if ($this->app->runningInConsole()) {
45
            $this->commands([
46
                ListEventsCommand::class,
47
                CreateEventCommand::class,
48
                EditEventCommand::class,
49
                ShowEventCommand::class,
50
                DeleteEventCommand::class
51
            ]);
52
        }
53
    }
54
55
    private function defineRoutes()
56
    {
57
        $this->defineWebRoutes();
58
        $this->defineApiRoutes();
59
    }
60
61
    protected function defineWebRoutes()     {
62
        require EVENTS_PATH . '/routes/web.php';
63
    }
64
65
    protected function defineApiRoutes()     {
66
        require EVENTS_PATH . '/routes/api.php';
67
    }
68
69
    private function loadViews()
70
    {
71
        $this->loadViewsFrom(EVENTS_PATH.'/resources/views', 'events');
72
    }
73
74
    private function loadMigrations()
75
    {
76
        $this->loadMigrationsFrom(EVENTS_PATH.'/database/migrations');
77
    }
78
79
    /**
80
     * Register factories.
81
     *
82
     * @param  string  $path
83
     * @return void
84
     */
85
    protected function registerEloquentFactoriesFrom($path)
86
    {
87
        $this->app->make(EloquentFactory::class)->load($path);
88
    }
89
}