-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queueing collections with multiple model types is not supported. #28
Comments
Are you using this package in a queued job somehow? This error comes from the getQueueableClass method, which is only used when the framework serializes models. |
Hi |
Can you share the complete Livewire component? |
You can workaround it by moving your query into a computed property. Then you may wish to pass the computed property into the view via the render method. Edit: My workaround seems to not work >= Livewire 2.6.0. |
Same issue using livewire, LogicException
|
What I did was convert map the collections to determine which model the item was from, add the type of model (maybe Product model) and convert it to an array. On the frontend, when looping over items, check if the item is equal to a Model and use the right properties for that item. There have been changes in the search syntax. Checkout the the package readme. // in your livewire component
public $searchQuery = '';
public array $searchResults = [];
public function updatedSearchQuery()
{
$results = [];
if (strlen($this->searchQuery) > 0) {
$results = Search::addMany([
[Product::activeSearchableResults(), 'name'],
[Brand::activeList(), 'name'],
[Category::activeSubCategories(), 'name'],
])->search(trim($this->searchQuery));
$this->searchResults = $results->map(fn($item) => [
'id' => $item->id,
'name' => $item->name,
'slug' => $item->slug,
'is_active' => $item->is_active,
'type' => class_basename($item)
])->toArray();
}
}
@foreach($searchResults as $res)
@if($res['type'] === 'Product')
<p> {{ $res['name'] }} </p>
@endforeach |
Hi
I am first time using this package.
I am trying to get search results from multiple models.
But I am receiving following error.
Kindly let me know, where I am doing wrong.
Thanks
The text was updated successfully, but these errors were encountered: