Searching Record in AttachAction

Accdording to the Docs, to search records to attach in a relationship manager one can specify the columns to search using this syntax: '''AttachAction::make() ->recordSelectSearchColumns(['title', 'description'])''' what if the title attribute is from another model that has a relationship with the current model? i tried using dot notation but not working e.g ([author.tittle'])
Solution:
was able to solve it
Jump to solution
4 Replies
Hussain4real
Hussain4real7mo ago
@awcodes your help is needed
Solution
Hussain4real
Hussain4real7mo ago
was able to solve it
Tieme
Tieme7mo ago
@Hussain4real Can you share your solution?
Hussain4real
Hussain4real7mo ago
sure
->recordSelect(function (Select $select) {
$multiple = $select->multiple();

$searchable = $multiple->searchable();

return $searchable->getSearchResultsUsing(function (string $search): array {
$students = Student::all()->unique();
$fullNames = $students->pluck('user.full_name')->unique();

return $fullNames->filter(function (string $fullName) use ($search): bool {
return str_contains(strtolower($fullName), strtolower($search));
})->toArray();
});

})
->recordSelect(function (Select $select) {
$multiple = $select->multiple();

$searchable = $multiple->searchable();

return $searchable->getSearchResultsUsing(function (string $search): array {
$students = Student::all()->unique();
$fullNames = $students->pluck('user.full_name')->unique();

return $fullNames->filter(function (string $fullName) use ($search): bool {
return str_contains(strtolower($fullName), strtolower($search));
})->toArray();
});

})