diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 65e9007..b52aeb5 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -63,6 +63,14 @@ class ModelsCommand extends Command */ protected $nullableColumns = []; + /** + * During initializtion we use Laravels Date Facade to + * determine the actual date class and store it here. + * + * @var string + */ + protected $dateClass; + /** * @param Filesystem $files */ @@ -103,6 +111,10 @@ class ModelsCommand extends Command } } + $this->dateClass = class_exists(\Illuminate\Support\Facades\Date::class) + ? '\\' . get_class(\Illuminate\Support\Facades\Date::now()) + : '\Illuminate\Support\Carbon'; + $content = $this->generateDocs($model, $ignore); if (!$this->write) { @@ -284,7 +296,7 @@ class ModelsCommand extends Command break; case 'date': case 'datetime': - $realType = '\Illuminate\Support\Carbon'; + $realType = $this->dateClass; break; case 'collection': $realType = '\Illuminate\Support\Collection'; @@ -348,7 +360,7 @@ class ModelsCommand extends Command foreach ($columns as $column) { $name = $column->getName(); if (in_array($name, $model->getDates())) { - $type = '\Illuminate\Support\Carbon'; + $type = $this->dateClass; } else { $type = $column->getType()->getName(); switch ($type) {