CrudServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Eliurkis\Crud;
4
5
use Illuminate\Support\ServiceProvider;
6
use Route;
7
8
class CrudServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        // Views Files
18
        $this->loadViewsFrom(resource_path('views/vendor/eliurkis/crud'), 'crud');
19
        $this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'crud');
20
21
        // Translation Files
22
        $this->loadTranslationsFrom(resource_path('lang/vendor'), 'eliurkis');
23
        $this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'eliurkis');
24
25
        // Publish Files
26
        $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/eliurkis')], 'lang');
27
        $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/eliurkis/crud')], 'views');
28
    }
29
30
    /**
31
     * Register the application services.
32
     *
33
     * @return void
34
     */
35
    public function register()
36
    {
37
        include __DIR__.'/routes.php';
38
39
        // Register provider dependencies
40
        $this->app->register(\Collective\Html\HtmlServiceProvider::class);
41
42
        // Register aliases dependencies
43
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
44
        $loader->alias('Form', \Collective\Html\FormFacade::class);
45
        $loader->alias('Html', \Collective\Html\HtmlFacade::class);
46
        $loader->alias('Carbon', \Carbon\Carbon::class);
47
    }
48
49
    public static function resource($name, $controller)
50
    {
51
        Route::resource($name, $controller, ['parameters' => [
52
            $name => 'id',
53
        ]]);
54
        Route::get($name.'/{id}/delete', $controller.'@destroy')->name($name.'.destroy');
55
    }
56
}
57