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

CrudServiceProvider::resource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
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