Skip to content

Commit

Permalink
Added registerDBALTypes() function to DatabaseServiceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Dec 13, 2020
1 parent a3f8589 commit a5761d4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Illuminate/Database/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Database;

use Doctrine\DBAL\Types\Type;
use Faker\Factory as FakerFactory;
use Faker\Generator as FakerGenerator;
use Illuminate\Contracts\Queue\EntityResolver;
Expand Down Expand Up @@ -45,6 +46,30 @@ public function register()
$this->registerEloquentFactory();

$this->registerQueueableEntityResolver();

$this->registerDBALTypes();
}

/**
* Add any custom types to the DBAL library.
*
* @return void
*/
protected function registerDBALTypes()
{
if (! class_exists(Type::class)) {
return;
}

$types = config('database.dbal.types');

if (! is_array($types)) {
return;
}

foreach ($types as $typeName => $typeClassDefinition) {
\Schema::registerCustomDoctrineType($typeClassDefinition, $typeName, $typeName);
}
}

/**
Expand Down

0 comments on commit a5761d4

Please sign in to comment.