31
31
use Illuminate \Database \Eloquent \Casts \AsStringable ;
32
32
use Illuminate \Support \Arr ;
33
33
use Illuminate \Support \Collection ;
34
+ use Illuminate \Support \Facades \Schema ;
34
35
use Illuminate \Support \Str ;
35
36
use RuntimeException ;
36
37
@@ -45,13 +46,6 @@ class RealTimeFactory extends Factory
45
46
*/
46
47
protected $ modelInstance ;
47
48
48
- /**
49
- * The database schema manager for the model.
50
- *
51
- * @var \Doctrine\DBAL\Schema\AbstractSchemaManager
52
- */
53
- protected $ schema ;
54
-
55
49
/**
56
50
* The table name for the model.
57
51
*
@@ -85,7 +79,6 @@ public function configure(): self
85
79
$ modelName = $ this ->modelName ();
86
80
$ this ->modelInstance = new $ modelName ;
87
81
$ connection = $ this ->modelInstance ->getConnection ();
88
- $ this ->schema = $ connection ->getDoctrineSchemaManager ();
89
82
$ this ->table = $ this ->modelInstance ->getConnection ()->getTablePrefix ().$ this ->modelInstance ->getTable ();
90
83
$ this ->registerTypeMappings ($ connection ->getDoctrineConnection ()->getDatabasePlatform ());
91
84
@@ -130,7 +123,7 @@ public static function new($attributes = [])
130
123
*/
131
124
protected function getColumnsFromModel (): Collection
132
125
{
133
- $ columns = $ this -> schema -> listTableColumns ($ this ->table );
126
+ $ columns = Schema:: getColumns ($ this ->table );
134
127
135
128
return collect ($ columns )->keyBy (fn ($ column ) => $ column ->getName ());
136
129
}
@@ -156,7 +149,7 @@ protected function value(Column $column): mixed
156
149
*/
157
150
protected function isForeignKey (Column $ column ): bool
158
151
{
159
- return collect ($ this -> schema -> listTableForeignKeys ($ this ->table ))
152
+ return collect (Schema:: getForeignKeys ($ this ->table ))
160
153
->filter (fn ($ foreignKey ) => in_array ($ column ->getName (), $ foreignKey ->getLocalColumns ()))
161
154
->isNotEmpty ();
162
155
}
@@ -166,7 +159,7 @@ protected function isForeignKey(Column $column): bool
166
159
*/
167
160
protected function isPrimaryKey (Column $ column ): bool
168
161
{
169
- return collect ($ this -> schema -> listTableIndexes ($ this ->table ))
162
+ return collect (Schema:: getIndexes ($ this ->table ))
170
163
->some (fn (Index $ index ) => $ index ->isPrimary () && in_array ($ column ->getName (), $ index ->getColumns ()));
171
164
}
172
165
0 commit comments