77use Astrotomic \Translatable \Contracts \Translatable ;
88use Barryvdh \LaravelIdeHelper \Console \ModelsCommand ;
99use Barryvdh \LaravelIdeHelper \Contracts \ModelHookInterface ;
10- use Illuminate \Contracts \Config \Repository as Config ;
1110use Illuminate \Database \Eloquent \Model ;
12- use Illuminate \Support \Facades \Schema ;
1311
1412class 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}
0 commit comments