Skip to content

Commit 8a8239d

Browse files
committed
WIP
1 parent 39c74c1 commit 8a8239d

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

application/controllers/UsageController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function indexAction()
8181
} else {
8282
$this->addControl($searchBar);
8383
$this->sendMultipartUpdate();
84-
return true;
84+
return;
8585
}
8686
} else {
8787
$filter = $searchBar->getFilter();

library/X509/Web/Control/SearchBar/ObjectSuggestions.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public function setModel($model): self
4141
return $this;
4242
}
4343

44+
protected function shouldShowRelationFor(string $column): bool
45+
{
46+
$columns = Str::trimSplit($column, '.');
47+
48+
return $columns[0] !== $this->model->getTableName();
49+
}
50+
4451
protected function createQuickSearchFilter($searchTerm)
4552
{
4653
$model = $this->model;
@@ -161,15 +168,21 @@ protected static function collectRelations(Resolver $resolver, Model $subject, a
161168
foreach ($resolver->getRelations($subject) as $name => $relation) {
162169
/** @var Relation $relation */
163170
$isHasOne = $relation instanceof HasOne;
164-
if (empty($path)) {
165-
$relationPath = [$name];
166-
if ($isHasOne && empty($path)) {
171+
$relationPath = [$name];
172+
173+
if (! isset($models[$name]) && ! in_array($name, $path, true)) {
174+
if ($isHasOne) {
167175
array_unshift($relationPath, $subject->getTableName());
168176
}
169177

170178
$relationPath = array_merge($path, $relationPath);
171-
$models[join('.', $relationPath)] = $relation->getTarget();
172-
self::collectRelations($resolver, $relation->getTarget(), $models, $relationPath);
179+
$targetPath = join('.', $relationPath);
180+
181+
if (! isset($models[$targetPath])) {
182+
$models[$targetPath] = $relation->getTarget();
183+
self::collectRelations($resolver, $relation->getTarget(), $models, $relationPath);
184+
return;
185+
}
173186
}
174187
}
175188
}

0 commit comments

Comments
 (0)