Completed
Push — master ( 4e528e...b698b3 )
by ARCANEDEV
04:17
created

LaravelMessengerServiceProvider::bindModels()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 8
nc 2
nop 0
1
<?php namespace Arcanedev\LaravelMessenger;
2
3
use Arcanedev\LaravelMessenger\Contracts as MessengerContracts;
4
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
5
6
/**
7
 * Class     LaravelMessengerServiceProvider
8
 *
9
 * @package  Arcanedev\LaravelMessenger
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class LaravelMessengerServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'laravel-messenger';
24
25
    /* ------------------------------------------------------------------------------------------------
26
     |  Getters & Setters
27
     | ------------------------------------------------------------------------------------------------
28
     */
29
    /**
30
     * Get the base path of the package.
31
     *
32
     * @return string
33
     */
34
    public function getBasePath()
35
    {
36
        return dirname(__DIR__);
37
    }
38
39
    /* ------------------------------------------------------------------------------------------------
40
     |  Main Functions
41
     | ------------------------------------------------------------------------------------------------
42
     */
43
    /**
44
     * Register the service provider.
45
     */
46
    public function register()
47
    {
48
        $this->registerConfig();
49
        $this->bindModels();
50
    }
51
52
    /**
53
     * Boot the service provider.
54
     */
55
    public function boot()
56
    {
57
        parent::boot();
58
59
        $this->publishConfig();
60
        $this->publishMigrations();
61
    }
62
63
    /**
64
     * Get the services provided by the provider.
65
     *
66
     * @return array
67
     */
68
    public function provides()
69
    {
70
        return [
71
            MessengerContracts\Discussion::class,
72
            MessengerContracts\Message::class,
73
            MessengerContracts\Participant::class,
74
        ];
75
    }
76
77
    /* ------------------------------------------------------------------------------------------------
78
     |  Other Functions
79
     | ------------------------------------------------------------------------------------------------
80
     */
81
    /**
82
     * Bind the models.
83
     */
84
    private function bindModels()
85
    {
86
        $config   = $this->config();
87
        $bindings = [
88
            'discussions'  => MessengerContracts\Discussion::class,
89
            'messages'     => MessengerContracts\Message::class,
90
            'participants' => MessengerContracts\Participant::class,
91
        ];
92
93
        foreach ($bindings as $key => $contract) {
94
            $this->bind($contract, $config->get("laravel-messenger.$key.model"));
95
        }
96
    }
97
}
98