I making a live wire component for filter products but I have a error on Livewire
<?php
namespace App\Http\Livewire;
use App\Models\Area;
use Livewire\Component;
use App\Models\Simulator;
class FilterSimulators extends Component
{
public $areas;
public $simulators;
public function mount(){
$this->areas = Area::get();
$this->simulators = Simulator::orderBy('name', 'desc')->get();
}
public function filterByArea($type)
{
$this->simulators = Simulator::orderBy('name', 'desc')->get();
}
public function render()
{
return view('livewire.filter-simulators');
}
}
and the Livewire component
<div>
<div class="has-text-centered">
<ul class="list-filter-simulators">
@foreach ($areas as $area)
<li class="mx-15">
<a href="#" wire:click.prevent="filterByArea('{{ $area->slug }}')" class="text-sm">{{ $area->name }}</a>
</li>
@endforeach
</ul>
</div>
<div class="columns is-multiline mt-45">
@foreach ($simulators as $simulator)
<div class="column m-15 widget-simulator" style="background-image: url('/img/simulator01.webp')">
<h4 class="text-white is-size-5 text-bold">{{ $simulator->name }}</h4>
</div>
@endforeach
</div>
</div>
and when I press anchor filterByArea show a popup (I remove logic of filter Eloquent for simplify example)
Livewire\Exceptions\CorruptComponentPayloadException Livewire encountered corrupt data when trying to hydrate the [filter-simulators] component. Ensure that the [name, id, data] of the Livewire component wasn't tampered with between requests.
I search and try to convert $simulators to protecto and add to return view manually but I get the same error, maybe because this is my first day using Live Wire hahaha, and the beginning the component show my all data correctly only when I press a button launch the error, I hope someone can help me :)
Thanks! Regards!