MessengerServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Aurawindsurfing\Messenger;
4
5
use Illuminate\Support\ServiceProvider;
6
use Aurawindsurfing\Messenger\Console\DeleteAllData;
7
use Aurawindsurfing\Messenger\Console\GenerateDummyMessages;
8
9
class MessengerServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14
    public function boot()
15
    {
16
        /*
17
         * Optional methods to load your package assets
18
         */
19
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'messenger');
20
        $this->loadRoutesFrom(__DIR__.'/../routes/web.php');
21
22
        if ($this->app->runningInConsole()) {
23
            //Publishing config files.
24
            $this->publishes([
25
                __DIR__.'/../config/config.php' => config_path('messenger.php'),
26
            ], 'config');
27
28
            // Publishing the views.
29
            $this->publishes([
30
                __DIR__.'/../resources/views' => resource_path('views/vendor/messenger'),
31
            ], 'views');
32
33
            // Publishing the migration files.
34 View Code Duplication
            if (empty(glob(database_path('migrations/*_create_threads_table.php')))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
                $this->publishes([
36
                    __DIR__.'/../database/migrations/0000_00_00_000000_create_threads_table.php' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_threads_table.php'),
37
                ], 'migrations');
38
            }
39
40
            // Publishing the migration files.
41 View Code Duplication
            if (empty(glob(database_path('migrations/*_create_messages_table.php')))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
                $this->publishes([
43
                    __DIR__.'/../database/migrations/0000_00_00_000000_create_messages_table.php' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_messages_table.php'),
44
                ], 'migrations');
45
            }
46
47
            // Registering package commands.
48
            $this->commands([
49
                GenerateDummyMessages::class,
50
                DeleteAllData::class,
51
            ]);
52
        }
53
    }
54
55
    /**
56
     * Register the application services.
57
     */
58
    public function register()
59
    {
60
        // Automatically apply the package configuration
61
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'messenger');
62
63
        // Register package factories to use with main application
64
        $this->app->make('Illuminate\Database\Eloquent\Factory')->load(__DIR__.'/../database/factories');
65
    }
66
}
67