@@ -34,34 +34,27 @@ public function __construct(
3434 */
3535 public function create (): ModelProperty
3636 {
37- $ vars = $ this ->schema ->__debugInfo ( );
38- $ default = $ vars [ ' columns ' ][ $ this -> columnName ] ['default ' ] ?? '' ;
37+ $ column = $ this ->schema ->getColumn ( $ this -> columnName );
38+ $ default = $ column ['default ' ] ?? '' ;
3939
4040 return (new ModelProperty ())
4141 ->setName ($ this ->columnName )
4242 ->setType ($ this ->schema ->getColumnType ($ this ->columnName ))
4343 ->setDefault ((string )$ default )
44- ->setIsPrimaryKey ($ this ->isPrimaryKey ($ vars , $ this -> columnName ))
44+ ->setIsPrimaryKey ($ this ->isPrimaryKey ())
4545 ->setIsHidden (in_array ($ this ->columnName , $ this ->entity ->getHidden ()))
4646 ->setIsAccessible ($ this ->isAccessible ())
4747 ->setValidationSet ($ this ->table ->validationDefault (new Validator ())->field ($ this ->columnName ));
4848 }
4949
5050 /**
51- * @param array $schemaDebugInfo debug array from TableSchema
52- * @param string $columnName column name
51+ * Checks if this column is part of the primary key.
52+ *
5353 * @return bool
5454 */
55- private function isPrimaryKey (array $ schemaDebugInfo , string $ columnName ): bool
55+ private function isPrimaryKey (): bool
5656 {
57- // ignore coverage since this condition should not be met
58- if (!isset ($ schemaDebugInfo ['constraints ' ]['primary ' ]['columns ' ])) {
59- // @codeCoverageIgnoreStart
60- return false ;
61- // @codeCoverageIgnoreEnd
62- }
63-
64- return in_array ($ columnName , $ schemaDebugInfo ['constraints ' ]['primary ' ]['columns ' ]);
57+ return in_array ($ this ->columnName , $ this ->schema ->getPrimaryKey ());
6558 }
6659
6760 /**
0 commit comments