Issues (56)

src/Provider/ContactServiceProvider.php (4 issues)

1
<?php
2
3
namespace Adminetic\Contact\Provider;
4
5
use Livewire\Livewire;
0 ignored issues
show
The type Livewire\Livewire was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Support\Facades\Gate;
7
use Illuminate\Support\Facades\Route;
8
use Illuminate\Support\ServiceProvider;
9
use Adminetic\Contact\Models\Admin\Contact;
10
use Adminetic\Contact\Policies\ContactPolicy;
11
use Adminetic\Contact\Repositories\ContactRepository;
12
use Adminetic\Contact\Contracts\ContactRepositoryInterface;
13
use Adminetic\Contact\Contracts\GroupRepositoryInterface;
14
use Adminetic\Contact\Http\Livewire\Admin\Contact\ContactTable;
15
use Adminetic\Contact\Http\Livewire\Admin\Contact\ToggleActiveContact;
16
use Adminetic\Contact\Http\Livewire\Admin\Contact\ToggleFavoriteContact;
17
use Adminetic\Contact\Repositories\GroupRepository;
18
19
class ContactServiceProvider extends ServiceProvider
20
{
21
    // Register Policies
22
    protected $policies = [
23
        Contact::class => ContactPolicy::class,
24
    ];
25
26
    /**
27
     * Bootstrap services.
28
     *
29
     * @return void
30
     */
31
    public function boot()
32
    {
33
        // Publish Ressource
34
        if ($this->app->runningInConsole()) {
35
            $this->publishResource();
36
        }
37
        // Register Resources
38
        $this->registerResource();
39
        // Register Policies
40
        $this->registerPolicies();
41
        // Register Livewire Components
42
        $this->registerLivewire();
43
    }
44
45
    /**
46
     * Register services.
47
     *
48
     * @return void
49
     */
50
    public function register()
51
    {
52
        /* Repository Interface Binding */
53
        $this->repos();
54
    }
55
56
    /**
57
     * Publish Package Resource.
58
     *
59
     *@return void
60
     */
61
    protected function publishResource()
62
    {
63
        // Publish Config File
64
        $this->publishes([
65
            __DIR__ . '/../../config/contact.php' => config_path('contact.php'),
66
        ], 'contact-config');
67
        // Publish View Files
68
        $this->publishes([
69
            __DIR__ . '/../../resources/views' => resource_path('views/vendor/adminetic/plugin/contact'),
70
        ], 'contact-views');
71
        // Publish Migration Files
72
        $this->publishes([
73
            __DIR__ . '/../../database/migrations' => database_path('migrations'),
74
        ], 'contact-migrations');
75
    }
76
77
    /**
78
     * Register Package Resource.
79
     *
80
     *@return void
81
     */
82
    protected function registerResource()
83
    {
84
        $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); // Loading Migration Files
85
        $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'contact'); // Loading Views Files
86
        $this->registerRoutes();
87
    }
88
89
    /**
90
     * Register Routes.
91
     *
92
     * @return void
93
     */
94
    protected function registerRoutes()
95
    {
96
        Route::group($this->routeConfiguration(), function () {
0 ignored issues
show
$this->routeConfiguration() of type void is incompatible with the type Closure|array|string expected by parameter $attributes of Illuminate\Support\Facades\Route::group(). ( Ignorable by Annotation )

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

96
        Route::group(/** @scrutinizer ignore-type */ $this->routeConfiguration(), function () {
Loading history...
Are you sure the usage of $this->routeConfiguration() targeting Adminetic\Contact\Provid...r::routeConfiguration() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
97
            $this->loadRoutesFrom(__DIR__ . '/../../routes/web.php');
98
        });
99
    }
100
101
    /**
102
     * Register Route Configuration.
103
     *
104
     * @return void
105
     */
106
    protected function routeConfiguration()
107
    {
108
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array('prefix' =>... array('web', 'auth'))) returns the type array which is incompatible with the documented return type void.
Loading history...
109
            'prefix' => config('contact.prefix', 'admin'),
110
            'middleware' => config('contact.middleware', ['web', 'auth']),
111
        ];
112
    }
113
114
    /**
115
     * Register Livewire Components
116
     *
117
     *@return void
118
     */
119
    protected function registerLivewire()
120
    {
121
        Livewire::component('admin.contact.contact-table', ContactTable::class);
122
        Livewire::component('admin.contact.toggle-active-contact', ToggleActiveContact::class);
123
        Livewire::component('admin.contact.toggle-favorite-contact', ToggleFavoriteContact::class);
124
    }
125
126
127
    /**
128
     * Repository Binding.
129
     *
130
     * @return void
131
     */
132
    protected function repos()
133
    {
134
        $this->app->bind(ContactRepositoryInterface::class, ContactRepository::class);
135
        $this->app->bind(GroupRepositoryInterface::class, GroupRepository::class);
136
    }
137
138
    /**
139
     * Register Policies.
140
     *
141
     *@return void
142
     */
143
    protected function registerPolicies()
144
    {
145
        foreach ($this->policies as $key => $value) {
146
            Gate::policy($key, $value);
147
        }
148
    }
149
}
150