Completed
Push — master ( d7dffa...54ccfb )
by Zhengchao
07:51
created

ReferralServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of questocat/laravel-referral package.
5
 *
6
 * (c) questocat <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Questocat\Referral;
13
14
use Illuminate\Support\ServiceProvider;
15
16
class ReferralServiceProvider extends ServiceProvider
17
{
18
    /**
19
     * Indicates if loading of the provider is deferred.
20
     *
21
     * @var bool
22
     */
23
    protected $defer = false;
24
25
    /**
26
     * Bootstrap the application events.
27
     */
28
    public function boot()
29
    {
30
        $this->setupConfig();
31
        $this->setupMigrations();
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function register()
38
    {
39
    }
40
41
    /**
42
     * Setup the config.
43
     */
44
    protected function setupConfig()
45
    {
46
        $source = realpath(__DIR__.'/../config/referral.php');
47
48
        $this->publishes([
49
            $source => config_path('referral.php'),
50
        ], 'config');
51
52
        $this->mergeConfigFrom($source, 'referral');
53
    }
54
55
    /**
56
     * Setup the migrations.
57
     */
58
    protected function setupMigrations()
59
    {
60
        $timestamp = date('Y_m_d_His');
61
        $migrationsSource = realpath(__DIR__.'/../database/migrations/add_referral_to_users_table.php');
62
        $migrationsTarget = database_path("/migrations/{$timestamp}_add_referral_to_users_table.php");
63
64
        $this->publishes([
65
            $migrationsSource => $migrationsTarget,
66
        ], 'migrations');
67
    }
68
}
69