-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a09298
commit 726b307
Showing
2 changed files
with
47 additions
and
11 deletions.
There are no files selected for viewing
38 changes: 29 additions & 9 deletions
38
src/Providers/LaravelIdeHelperHookPaperclipServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DanielDeWit\LaravelIdeHelperHookPaperclip\Providers; | ||
|
||
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; | ||
use DanielDeWit\LaravelIdeHelperHookPaperclip\Hooks\PaperclipHook; | ||
use Illuminate\Contracts\Config\Repository as Config; | ||
use Illuminate\Config\Repository; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Contracts\Support\DeferrableProvider; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class LaravelIdeHelperHookPaperclipServiceProvider extends ServiceProvider | ||
class LaravelIdeHelperHookPaperclipServiceProvider extends ServiceProvider implements DeferrableProvider | ||
{ | ||
/** | ||
* @return list<class-string<Command>> | ||
*/ | ||
public function provides(): array | ||
{ | ||
return [ | ||
ModelsCommand::class, | ||
]; | ||
} | ||
|
||
public function register(): void | ||
{ | ||
if ($this->app->isProduction()) { | ||
return; | ||
} | ||
$this->registerIdeHelperHook(); | ||
} | ||
|
||
/** @var Config $config */ | ||
protected function registerIdeHelperHook(): void | ||
{ | ||
/** @var Repository $config */ | ||
$config = $this->app->get('config'); | ||
|
||
$config->set('ide-helper.model_hooks', array_merge([ | ||
PaperclipHook::class, | ||
], (array) $config->get('ide-helper.model_hooks', []))); | ||
$config->set( | ||
'ide-helper.model_hooks', | ||
array_merge( | ||
[PaperclipHook::class], | ||
(array) $config->get('ide-helper.model_hooks', []), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters