File tree Expand file tree Collapse file tree 3 files changed +6
-40
lines changed Expand file tree Collapse file tree 3 files changed +6
-40
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,13 @@ function getPrimaryKeySequence(string $table): ?string;
58
58
* Returns hasMany reference.
59
59
* If a targetTable is not provided, returns references for all tables.
60
60
*/
61
- function getHasManyReference (string $ table, ? string $ targetTable = null ): ?array ;
61
+ function getHasManyReference (string $ table ): ?array ;
62
62
63
63
/**
64
64
* Returns belongsTo reference.
65
65
* If a column is not provided, returns references for all columns.
66
66
*/
67
- function getBelongsToReference (string $ table, ? string $ column = null ): ?array ;
67
+ function getBelongsToReference (string $ table ): ?array ;
68
68
69
69
/**
70
70
* Rebuilds database structure cache.
Original file line number Diff line number Diff line change @@ -114,41 +114,19 @@ public function getPrimaryKeySequence(string $table): ?string
114
114
}
115
115
116
116
117
- public function getHasManyReference (string $ table, ? string $ targetTable = null ): ? array
117
+ public function getHasManyReference (string $ table ): array
118
118
{
119
119
$ this ->needStructure ();
120
120
$ 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 ] ?? [];
135
122
}
136
123
137
124
138
- public function getBelongsToReference (string $ table, ? string $ column = null ): ? array
125
+ public function getBelongsToReference (string $ table ): array
139
126
{
140
127
$ this ->needStructure ();
141
128
$ 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 ] ?? [];
152
130
}
153
131
154
132
Original file line number Diff line number Diff line change @@ -148,11 +148,6 @@ class StructureTestCase extends TestCase
148
148
Assert::same ([
149
149
'Books ' => ['author_id ' , 'translator_id ' ],
150
150
], $ this ->structure ->getHasManyReference ('authors ' ));
151
-
152
- Assert::same (
153
- ['author_id ' , 'translator_id ' ],
154
- $ this ->structure ->getHasManyReference ('authors ' , 'books ' ),
155
- );
156
151
}
157
152
158
153
@@ -169,13 +164,6 @@ class StructureTestCase extends TestCase
169
164
'tag_id ' => 'tags ' ,
170
165
'book_id ' => 'Books ' ,
171
166
], $ 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 ' ));
179
167
}
180
168
181
169
You can’t perform that action at this time.
0 commit comments