Completed
Push — master ( 1d7aa3...5a5ab2 )
by Kazi Mainuddin
01:59
created

PayuServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 5

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 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Tzsk\Payu\Provider;
4
5
use Illuminate\Support\ServiceProvider;
6
use Tzsk\Payu\PayuGateway;
7
8
class PayuServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Perform post-registration booting of services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->publishFiles();
18
19
        $this->loadItems();
20
21
        /**
22
         * Register singleton.
23
         */
24
        $this->app->singleton('tzsk-payu', function($app) {
25
            return new PayuGateway();
26
        });
27
    }
28
29
    /**
30
     * Register any package services.
31
     *
32
     * @return void
33
     */
34
    public function register()
35
    {
36
        /**
37
         * Merge Configurations.
38
         */
39
        $this->mergeConfigFrom(
40
            __DIR__.'/../Config/tzsk-payu.php', 'payu'
41
        );
42
    }
43
44
    /**
45
     * Publish Config file and Migration File.
46
     */
47
    protected function publishFiles()
48
    {
49
        /**
50
         * Configurations that needs to be done by user.
51
         */
52
        $this->publishes([
53
            __DIR__.'/../Config/payu.php' => config_path('payu.php'),
54
        ], 'config');
55
56
        /**
57
         * Migration file for the payments.
58
         */
59
        $this->publishes([
60
            __DIR__.'/../Migration/' => database_path('migrations')
61
        ], 'migrations');
62
    }
63
64
    /**
65
     * Load Routes and Views.
66
     */
67
    protected function loadItems()
68
    {
69
        /**
70
         * Load routes for payment.
71
         */
72
        if (!$this->app->routesAreCached()) {
73
            require __DIR__.'/../Routes/routes.php';
74
        }
75
76
        /**
77
         * Load the Views.
78
         */
79
        $this->loadViewsFrom(__DIR__.'/../Views', 'tzsk');
80
    }
81
82
}
83