usamamuneerchaudhary /
commentify
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Usamamuneerchaudhary\Commentify\Providers; |
||
| 4 | |||
| 5 | use Illuminate\Support\Facades\Gate; |
||
| 6 | use Illuminate\Support\ServiceProvider; |
||
| 7 | use Livewire\Livewire; |
||
| 8 | use Usamamuneerchaudhary\Commentify\Http\Livewire\Comment; |
||
| 9 | use Usamamuneerchaudhary\Commentify\Http\Livewire\Comments; |
||
| 10 | use Usamamuneerchaudhary\Commentify\Http\Livewire\Like; |
||
| 11 | use Usamamuneerchaudhary\Commentify\Policies\CommentPolicy; |
||
| 12 | |||
| 13 | class CommentifyServiceProvider extends ServiceProvider |
||
| 14 | { |
||
| 15 | public function register(): void |
||
| 16 | { |
||
| 17 | $this->app->bind(CommentPolicy::class, function ($app) { |
||
|
0 ignored issues
–
show
|
|||
| 18 | return new CommentPolicy; |
||
| 19 | }); |
||
| 20 | |||
| 21 | Gate::policy(\Usamamuneerchaudhary\Commentify\Models\Comment::class, CommentPolicy::class); |
||
| 22 | |||
| 23 | $this->app->register(MarkdownServiceProvider::class); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function boot(): void |
||
| 27 | { |
||
| 28 | if ($this->app->runningInConsole()) { |
||
| 29 | // Publish config file |
||
| 30 | $this->publishes([ |
||
| 31 | __DIR__.'/../../config/commentify.php' => config_path('commentify.php'), |
||
| 32 | ], 'commentify-config'); |
||
| 33 | |||
| 34 | $this->publishes([ |
||
| 35 | __DIR__.'/../../tailwind.config.js' => base_path('tailwind.config.js'), |
||
| 36 | ], 'commentify-tailwind-config'); |
||
| 37 | |||
| 38 | // Publish Tailwind views |
||
| 39 | $this->publishes([ |
||
| 40 | __DIR__.'/../../resources/views/tailwind' => resource_path('views/vendor/commentify'), |
||
| 41 | ], 'commentify-tailwind-views'); |
||
| 42 | |||
| 43 | // Publish Bootstrap views |
||
| 44 | $this->publishes([ |
||
| 45 | __DIR__.'/../../resources/views/bootstrap' => resource_path('views/vendor/commentify'), |
||
| 46 | ], 'commentify-bootstrap-views'); |
||
| 47 | |||
| 48 | // Only register Filament views for publishing if Filament is installed |
||
| 49 | if (class_exists(\Filament\Facades\Filament::class)) { |
||
|
0 ignored issues
–
show
The type
Filament\Facades\Filament 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 50 | $this->publishes([ |
||
| 51 | __DIR__.'/../../resources/views/filament' => resource_path('views/vendor/commentify'), |
||
| 52 | ], 'commentify-filament-views'); |
||
| 53 | } |
||
| 54 | |||
| 55 | // Publish language files |
||
| 56 | $this->publishes([ |
||
| 57 | __DIR__.'/../../lang' => resource_path('../lang/vendor/commentify'), |
||
| 58 | ], 'commentify-lang'); |
||
| 59 | |||
| 60 | } |
||
| 61 | |||
| 62 | $migrationPath = realpath(__DIR__.'/../../database/migrations'); |
||
| 63 | if ($migrationPath && is_dir($migrationPath)) { |
||
| 64 | $this->loadMigrationsFrom($migrationPath); |
||
| 65 | } |
||
| 66 | |||
| 67 | // Load views based on CSS framework |
||
| 68 | $config = $this->app->make('config'); |
||
| 69 | $framework = $config->get('commentify.css_framework', 'tailwind'); |
||
| 70 | |||
| 71 | // Validate framework value |
||
| 72 | if (! in_array($framework, ['tailwind', 'bootstrap'])) { |
||
| 73 | $framework = 'tailwind'; |
||
| 74 | } |
||
| 75 | |||
| 76 | $frameworkPath = __DIR__.'/../../resources/views/'.$framework; |
||
| 77 | |||
| 78 | if (is_dir($frameworkPath)) { |
||
| 79 | $this->loadViewsFrom($frameworkPath, 'commentify'); |
||
| 80 | } else { |
||
| 81 | // Fallback to tailwind if framework directory doesn't exist |
||
| 82 | $this->loadViewsFrom(__DIR__.'/../../resources/views/tailwind', 'commentify'); |
||
| 83 | } |
||
| 84 | |||
| 85 | // Only load Filament views if Filament is installed |
||
| 86 | if (class_exists(\Filament\Facades\Filament::class)) { |
||
| 87 | $filamentPath = __DIR__.'/../../resources/views/filament'; |
||
| 88 | $filamentPathTailwind = __DIR__.'/../../resources/views/tailwind/filament'; |
||
| 89 | $filamentPathBootstrap = __DIR__.'/../../resources/views/bootstrap/filament'; |
||
| 90 | |||
| 91 | if (is_dir($filamentPath)) { |
||
| 92 | $this->loadViewsFrom($filamentPath, 'commentify'); |
||
| 93 | } elseif (is_dir($filamentPathTailwind)) { |
||
| 94 | $this->loadViewsFrom($filamentPathTailwind, 'commentify'); |
||
| 95 | } elseif (is_dir($filamentPathBootstrap)) { |
||
| 96 | $this->loadViewsFrom($filamentPathBootstrap, 'commentify'); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | $this->loadTranslationsFrom(__DIR__.'/../../lang', 'commentify'); |
||
| 101 | Livewire::component('comments', Comments::class); |
||
| 102 | Livewire::component('comment', Comment::class); |
||
| 103 | Livewire::component('like', Like::class); |
||
| 104 | } |
||
| 105 | } |
||
| 106 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.