LaravelTrixServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 29 2
A register() 0 8 1
1
<?php
2
3
namespace Te7aHoudini\LaravelTrix;
4
5
use Illuminate\Support\Facades\Blade;
6
use Illuminate\Support\Facades\Route;
7
use Illuminate\Support\ServiceProvider;
8
9
class LaravelTrixServiceProvider extends ServiceProvider
10
{
11
    public function boot()
12
    {
13
        if ($this->app->runningInConsole()) {
14
            $this->publishes([
15
                __DIR__.'/../config/laravel-trix.php' => config_path('laravel-trix.php'),
16
            ], 'config');
17
18
            $this->publishes([
19
                __DIR__.'/../database/migrations/create_trix_rich_texts_table.php.stub' => $this->app->databasePath().'/migrations/'.date('Y_m_d_His').'_create_trix_rich_texts_table.php',
20
            ], 'migrations');
21
        }
22
23
        Route::group([
24
            'prefix' => 'laravel-trix',
25
        ], function () {
26
            Route::post('attachment', config('laravel-trix.store_attachment_action'))->name('laravel-trix.store');
27
            Route::delete('attachment/{attachment}', config('laravel-trix.destroy_attachment_action'))->name('laravel-trix.destroy');
28
        });
29
30
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-trix');
31
32
        Blade::directive('trixassets', function () {
33
            return "<?php echo view('laravel-trix::trixassets')->render(); ?>";
34
        });
35
36
        Blade::directive('trix', function ($expression) {
37
            return "{!! app('laravel-trix')->make($expression) !!}";
38
        });
39
    }
40
41
    public function register()
42
    {
43
        $this->mergeConfigFrom(__DIR__.'/../config/laravel-trix.php', 'laravel-trix');
44
45
        $this->app->bind('laravel-trix', function ($app) {
46
            return $app->make(LaravelTrix::class);
47
        });
48
    }
49
}
50