ServiceProvider::loadViews()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Taskforcedev\CrudApi;
4
5
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
6
7
/**
8
 * Class ServiceProvider.
9
 *
10
 * @version 1.0.0
11
 */
12
class ServiceProvider extends IlluminateServiceProvider
13
{
14
    /**
15
     * Boot method.
16
     * Loads routes and configuration.
17
     */
18
    public function boot()
19
    {
20
        /* Load our routes */
21
        $this->loadRoutes();
22
        /* Load views */
23
        $this->loadViews();
24
        /* Register config file */
25
        $this->config();
26
    }
27
28
    /**
29
     * Registers the configuration.
30
     */
31
    public function register()
32
    {
33
        $this->mergeConfigFrom(
34
            __DIR__.'/../config/crudapi.php', 'crudapi'
35
        );
36
    }
37
38
    /**
39
     * Allows configuration to be publishable, this allows user to override
40
     * values without editing package.
41
     */
42
    protected function config()
43
    {
44
        $this->publishes(
45
            [
46
                __DIR__.'/../config/crudapi.php' => config_path('crudapi.php'),
47
            ], 'crudapi-config'
48
        );
49
    }
50
51
    /**
52
     * Load the package routes (if the file exists).
53
     */
54
    protected function loadRoutes()
55
    {
56
        $routes_path = __DIR__.'/Http/routes.php';
57
        if (file_exists($routes_path)) {
58
            include __DIR__.'/Http/routes.php';
59
        }
60
    }
61
62
    /**
63
     * Load the packages views.
64
     */
65
    protected function loadViews()
66
    {
67
        $view_path = __DIR__.'/../resources/views';
68
        $this->loadViewsFrom($view_path, 'crudapi');
69
        $this->publishes(
70
            [
71
                $view_path => base_path('resources/views/Taskforcedev/crudapi'),
72
            ], 'crudapi-views'
73
        );
74
    }
75
}
76