Skip to content

Commit 460dcd7

Browse files
committed
Use Schema methods
1 parent da248a6 commit 460dcd7

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/Illuminate/Database/Eloquent/Factories/RealTimeFactory.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Illuminate\Database\Eloquent\Casts\AsStringable;
3232
use Illuminate\Support\Arr;
3333
use Illuminate\Support\Collection;
34+
use Illuminate\Support\Facades\Schema;
3435
use Illuminate\Support\Str;
3536
use RuntimeException;
3637

@@ -45,13 +46,6 @@ class RealTimeFactory extends Factory
4546
*/
4647
protected $modelInstance;
4748

48-
/**
49-
* The database schema manager for the model.
50-
*
51-
* @var \Doctrine\DBAL\Schema\AbstractSchemaManager
52-
*/
53-
protected $schema;
54-
5549
/**
5650
* The table name for the model.
5751
*
@@ -85,7 +79,6 @@ public function configure(): self
8579
$modelName = $this->modelName();
8680
$this->modelInstance = new $modelName;
8781
$connection = $this->modelInstance->getConnection();
88-
$this->schema = $connection->getDoctrineSchemaManager();
8982
$this->table = $this->modelInstance->getConnection()->getTablePrefix().$this->modelInstance->getTable();
9083
$this->registerTypeMappings($connection->getDoctrineConnection()->getDatabasePlatform());
9184

@@ -130,7 +123,7 @@ public static function new($attributes = [])
130123
*/
131124
protected function getColumnsFromModel(): Collection
132125
{
133-
$columns = $this->schema->listTableColumns($this->table);
126+
$columns = Schema::getColumns($this->table);
134127

135128
return collect($columns)->keyBy(fn ($column) => $column->getName());
136129
}
@@ -156,7 +149,7 @@ protected function value(Column $column): mixed
156149
*/
157150
protected function isForeignKey(Column $column): bool
158151
{
159-
return collect($this->schema->listTableForeignKeys($this->table))
152+
return collect(Schema::getForeignKeys($this->table))
160153
->filter(fn ($foreignKey) => in_array($column->getName(), $foreignKey->getLocalColumns()))
161154
->isNotEmpty();
162155
}
@@ -166,7 +159,7 @@ protected function isForeignKey(Column $column): bool
166159
*/
167160
protected function isPrimaryKey(Column $column): bool
168161
{
169-
return collect($this->schema->listTableIndexes($this->table))
162+
return collect(Schema::getIndexes($this->table))
170163
->some(fn (Index $index) => $index->isPrimary() && in_array($column->getName(), $index->getColumns()));
171164
}
172165

0 commit comments

Comments
 (0)