File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,13 +58,13 @@ function getPrimaryKeySequence(string $table): ?string;
5858 * Returns hasMany reference.
5959 * If a targetTable is not provided, returns references for all tables.
6060 */
61- function getHasManyReference (string $ table, ? string $ targetTable = null ): ?array ;
61+ function getHasManyReference (string $ table ): ?array ;
6262
6363 /**
6464 * Returns belongsTo reference.
6565 * If a column is not provided, returns references for all columns.
6666 */
67- function getBelongsToReference (string $ table, ? string $ column = null ): ?array ;
67+ function getBelongsToReference (string $ table ): ?array ;
6868
6969 /**
7070 * Rebuilds database structure cache.
Original file line number Diff line number Diff line change @@ -114,41 +114,19 @@ public function getPrimaryKeySequence(string $table): ?string
114114 }
115115
116116
117- public function getHasManyReference (string $ table, ? string $ targetTable = null ): ? array
117+ public function getHasManyReference (string $ table ): array
118118 {
119119 $ this ->needStructure ();
120120 $ table = $ this ->resolveFQTableName ($ table );
121-
122- if ($ targetTable ) {
123- $ targetTable = $ this ->resolveFQTableName ($ targetTable );
124- foreach ($ this ->structure ['hasMany ' ][$ table ] as $ key => $ value ) {
125- if (strtolower ($ key ) === $ targetTable ) {
126- return $ this ->structure ['hasMany ' ][$ table ][$ key ];
127- }
128- }
129-
130- return null ;
131-
132- } else {
133- return $ this ->structure ['hasMany ' ][$ table ] ?? [];
134- }
121+ return $ this ->structure ['hasMany ' ][$ table ] ?? [];
135122 }
136123
137124
138- public function getBelongsToReference (string $ table, ? string $ column = null ): ? array
125+ public function getBelongsToReference (string $ table ): array
139126 {
140127 $ this ->needStructure ();
141128 $ table = $ this ->resolveFQTableName ($ table );
142-
143- if ($ column ) {
144- $ column = strtolower ($ column );
145- return isset ($ this ->structure ['belongsTo ' ][$ table ][$ column ])
146- ? [$ this ->structure ['belongsTo ' ][$ table ][$ column ], $ column ]
147- : null ;
148-
149- } else {
150- return $ this ->structure ['belongsTo ' ][$ table ] ?? [];
151- }
129+ return $ this ->structure ['belongsTo ' ][$ table ] ?? [];
152130 }
153131
154132
Original file line number Diff line number Diff line change @@ -148,11 +148,6 @@ class StructureTestCase extends TestCase
148148 Assert::same ([
149149 'Books ' => ['author_id ' , 'translator_id ' ],
150150 ], $ this ->structure ->getHasManyReference ('authors ' ));
151-
152- Assert::same (
153- ['author_id ' , 'translator_id ' ],
154- $ this ->structure ->getHasManyReference ('authors ' , 'books ' ),
155- );
156151 }
157152
158153
@@ -169,13 +164,6 @@ class StructureTestCase extends TestCase
169164 'tag_id ' => 'tags ' ,
170165 'book_id ' => 'Books ' ,
171166 ], $ this ->structure ->getBelongsToReference ('books_x_tags ' ));
172-
173- Assert::same (
174- ['Books ' , 'book_id ' ],
175- $ this ->structure ->getBelongsToReference ('books_x_tags ' , 'book_id ' ),
176- );
177-
178- Assert::null ($ this ->structure ->getBelongsToReference ('books_x_tags ' , 'non_exist ' ));
179167 }
180168
181169
You can’t perform that action at this time.
0 commit comments