Completed
Pull Request — master (#4)
by Eliurkis
01:41
created

CrudServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 4
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 1
A register() 0 6 1
A resource() 0 7 1
1
<?php
2
3
namespace Eliurkis\Crud;
4
5
use Route;
6
use Illuminate\Support\ServiceProvider;
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
        $this->app->make(\Eliurkis\Crud\CrudController::class);
39
        $this->app->register(\Collective\Html\HtmlServiceProvider::class);
40
    }
41
42
    public static function resource($name, $controller)
43
    {
44
        Route::resource($name, $controller, ['parameters' => [
45
            $name => 'id',
46
        ]]);
47
        Route::get($name.'/{id}/delete', $controller.'@destroy')->name($name.'.delete');
48
    }
49
}
50