Skip to content

Commit b23ac84

Browse files
committed
Fix deferred provider
1 parent 2f05c17 commit b23ac84

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/Hooks/TranslatableHook.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77
use Astrotomic\Translatable\Contracts\Translatable;
88
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
99
use Barryvdh\LaravelIdeHelper\Contracts\ModelHookInterface;
10-
use Illuminate\Contracts\Config\Repository as Config;
1110
use Illuminate\Database\Eloquent\Model;
12-
use Illuminate\Support\Facades\Schema;
1311

1412
class TranslatableHook implements ModelHookInterface
1513
{
1614
public function run(ModelsCommand $command, Model $model): void
1715
{
1816
if (
19-
! $model instanceof Translatable ||
20-
! method_exists($model, 'getTranslationModelName') ||
21-
! property_exists($model, 'translatedAttributes')
17+
! $model instanceof Translatable || ! method_exists($model, 'getTranslationModelName') || ! property_exists($model, 'translatedAttributes')
2218
) {
2319
return;
2420
}
@@ -28,7 +24,7 @@ public function run(ModelsCommand $command, Model $model): void
2824
/** @var Model $modelTranslation */
2925
$modelTranslation = $command->getLaravel()->make($className);
3026

31-
$table = $modelTranslation->getConnection()->getTablePrefix() . $modelTranslation->getTable();
27+
$table = $modelTranslation->getConnection()->getTablePrefix().$modelTranslation->getTable();
3228

3329
$columns = $modelTranslation->getConnection()->getSchemaBuilder()->getColumns($table);
3430

@@ -97,4 +93,11 @@ public function run(ModelsCommand $command, Model $model): void
9793
);
9894
}
9995
}
96+
97+
protected function getDateClass(): string
98+
{
99+
return class_exists(\Illuminate\Support\Facades\Date::class)
100+
? '\\'.get_class(\Illuminate\Support\Facades\Date::now())
101+
: '\Illuminate\Support\Carbon';
102+
}
100103
}

src/Providers/LaravelIdeHelperHookTranslatableServiceProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
88
use DanielDeWit\LaravelIdeHelperHookTranslatable\Hooks\TranslatableHook;
9-
use Illuminate\Console\Command;
109
use Illuminate\Contracts\Config\Repository as Config;
1110
use Illuminate\Contracts\Support\DeferrableProvider;
1211
use Illuminate\Support\ServiceProvider;
@@ -16,10 +15,10 @@ class LaravelIdeHelperHookTranslatableServiceProvider extends ServiceProvider im
1615
/**
1716
* @var string
1817
*/
19-
const ModelsCommandAlias = 'laravel-ide-helper-hook-translatable-command-alias';
18+
const ModelsCommandAlias = 'ModelsCommand__LaravelIdeHelperHookTranslatable__alias';
2019

2120
/**
22-
* @return list<class-string<Command>|string>
21+
* @return list<string>
2322
*/
2423
public function provides(): array
2524
{

0 commit comments

Comments
 (0)