Completed
Push — master ( 13e440...4b30b5 )
by Ashish
05:11
created

TwoFactorAuthenticationServiceProvider::boot()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 1
Metric Value
c 5
b 1
f 1
dl 0
loc 26
rs 8.8571
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Thecodework\TwoFactorAuthentication;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\ServiceProvider;
7
8
class TwoFactorAuthenticationServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Perform post-registration booting of services.
12
     * Loading Routes, Views and Migrations.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->loadRoutesFrom(__DIR__ . '/routes/routes.php');
19
        $this->loadViewsFrom(__DIR__ . '/../resources/views', '2fa');
20
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
21
22
        // Publishing configuration file
23
        $this->publishes([
24
            __DIR__ . '/../config/2fa-config.php' => config_path('2fa-config.php'),
25
        ], 'config');
26
27
        // Publishing migration
28
        $this->publishes([
29
            __DIR__ . '/../database/migrations/' => database_path('migrations'),
30
        ], 'migrations');
31
32
        // Publishing views
33
        $this->publishes([
34
            __DIR__ . '/../resources/views/' => resource_path('views/vendor/2fa'),
35
        ], 'views');
36
37
        // Publishing assets
38
        $this->publishes([
39
            __DIR__ . '/../public/js/' => public_path('js'),
40
        ]);
41
    }
42
43
    /**
44
     * Get User moded defined in config file.
45
     *
46
     * @return string
47
     */
48
    public static function determineTwoFAModel(): string
49
    {
50
        return config('2fa-config.model');
51
    }
52
53
    /**
54
     * Get User Model Instance.
55
     *
56
     * @return \Illuminate\Database\Eloquent\Model
57
     */
58
    public static function getTwoFAModelInstance(): Model
59
    {
60
        $TwoFAModelClassName = self::determineTwoFAModel();
61
62
        return new $TwoFAModelClassName();
63
    }
64
}
65