All the Attibutes came back null
thecyrilcril opened this issue · 4 comments
Spatie\Searchable\SearchResultCollection {#204 ▼
#items: array:1 [▼
0 => Spatie\Searchable\SearchResult {#345 ▼
+searchable: App\Account {#364 ▶}
+account_number: null
+firstname: null
+lastname: null
+residential_address: null
+office_address: null
+business_type: null
+created_on: null
+url: "//localhost:3000/account/clients/AC9595676"
+type: "accounts"
}
]
}
Here is my code, which is literaly what I copied in the docs
$results = (new Search())
->registerModel(Account::class, function(ModelSearchAspect $modelSearchAspect) {
$modelSearchAspect
->addExactSearchableAttribute('account_number')
->addSearchableAttribute('firstname')
->addSearchableAttribute('lastname')
->addSearchableAttribute('residential_address')
->addSearchableAttribute('office_address')
->addSearchableAttribute('business_type')
->addSearchableAttribute('created_on')
->with('current_marketer');
})->search($request->input('q'));
How do I proceed? How do I get the result. the attributes in the Searchable key displays a model matching my search but how do I display it in my blade files
Did you follow the guide on how to render the results? https://github.com/spatie/laravel-searchable#rendering-search-results
Did you follow the guide on how to render the results? https://github.com/spatie/laravel-searchable#rendering-search-results
I didn't but when I did all the null attributes rendered blank in my html
Okay, it's weird that the Spatie\Searchable\SearchResult
instance in the collection contains all those attributes, it should only have searchable
, title
, and url
. Can you share the implementation of the getSearchResult()
method in your Account
model?
Closing this due to inactivity. Feel free to open a new issue if you're still having issues.