CategoriesServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 13 1
A boot() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Categories\Providers;
6
7
use Rinvex\Categories\Models\Category;
8
use Illuminate\Support\ServiceProvider;
9
use Rinvex\Support\Traits\ConsoleTools;
10
use Rinvex\Categories\Console\Commands\MigrateCommand;
11
use Rinvex\Categories\Console\Commands\PublishCommand;
12
use Rinvex\Categories\Console\Commands\RollbackCommand;
13
14
class CategoriesServiceProvider extends ServiceProvider
15
{
16
    use ConsoleTools;
17
18
    /**
19
     * The commands to be registered.
20
     *
21
     * @var array
22
     */
23
    protected $commands = [
24
        MigrateCommand::class => 'command.rinvex.categories.migrate',
25
        PublishCommand::class => 'command.rinvex.categories.publish',
26
        RollbackCommand::class => 'command.rinvex.categories.rollback',
27
    ];
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function register()
33
    {
34
        // Merge config
35
        $this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'rinvex.categories');
36
37
        // Bind eloquent models to IoC container
38
        $this->registerModels([
39
            'rinvex.categories.category' => Category::class,
40
        ]);
41
42
        // Register console commands
43
        $this->registerCommands($this->commands);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function boot()
50
    {
51
        // Publish Resources
52
        $this->publishesConfig('rinvex/laravel-categories');
53
        $this->publishesMigrations('rinvex/laravel-categories');
54
        ! $this->autoloadMigrations('rinvex/laravel-categories') || $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
55
    }
56
}
57