CommentifyServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 1
Metric Value
cc 2
eloc 19
c 5
b 1
f 1
nc 2
nop 0
dl 0
loc 28
rs 9.6333
1
<?php
2
3
namespace Usamamuneerchaudhary\Commentify\Providers;
4
5
6
use Illuminate\Support\Facades\Gate;
7
use Illuminate\Support\ServiceProvider;
8
use Livewire\Livewire;
9
use Usamamuneerchaudhary\Commentify\Http\Livewire\Comment;
10
use Usamamuneerchaudhary\Commentify\Http\Livewire\Comments;
11
use Usamamuneerchaudhary\Commentify\Http\Livewire\Like;
12
use Usamamuneerchaudhary\Commentify\Policies\CommentPolicy;
13
14
class CommentifyServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * @return void
18
     */
19
    public function register(): void
20
    {
21
        $this->app->bind(CommentPolicy::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
        $this->app->bind(CommentPolicy::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
            return new CommentPolicy;
23
        });
24
25
        Gate::policy(\Usamamuneerchaudhary\Commentify\Models\Comment::class, CommentPolicy::class);
26
27
        $this->app->register(MarkdownServiceProvider::class);
28
    }
29
30
31
    /**
32
     * @return void
33
     */
34
    public function boot(): void
35
    {
36
        if ($this->app->runningInConsole()) {
37
            // Publish config file
38
            $this->publishes([
39
                __DIR__.'/../../config/commentify.php' => config_path('commentify.php'),
40
            ], 'commentify-config');
41
42
            $this->publishes([
43
                __DIR__.'/../../tailwind.config.js' => base_path('tailwind.config.js'),
44
            ], 'commentify-tailwind-config');
45
46
            // Add this line to publish your views
47
            $this->publishes([
48
                __DIR__.'/../../resources/views' => resource_path('views/vendor/commentify'),
49
            ], 'commentify-views');
50
51
            // Publish language files
52
            $this->publishes([
53
                __DIR__.'/../../lang' => resource_path('../lang/vendor/commentify'),
54
            ], 'commentify-lang');
55
        }
56
        $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
57
        $this->loadViewsFrom(__DIR__.'/../../resources/views', 'commentify');
58
        $this->loadTranslationsFrom(__DIR__.'/../../lang', 'commentify');
59
        Livewire::component('comments', Comments::class);
60
        Livewire::component('comment', Comment::class);
61
        Livewire::component('like', Like::class);
62
    }
63
}
64