This is my function to delete a search record from the database. I expect the DB changes to be rendered without a page refresh. and that's y I use livewire. but after clicking delete, the page is updated only after refresh. the dd results don't show updated results.
public function deleteSearch($search) {
$empsearch = Auth::user()->mySearches->find($search);
$empsearch->delete();
$this->skills = Auth()->user()->mySearches;
dd($this->skills);
}
Blade file
@if (count($skills) > 0)
@foreach ($skills as $search)
<div class="el-tag" >
<a href="/search?query={{ $search->name }}">
{{ $search->name }}
</a>
|
<a onclick="return confirm('Are you sure?')" wire:click.prevent="deleteSearch({{ $search->search_id }})" >
<i class="pl-1 icon el-icon-delete"></i>
</a>
</div>
@endforeach
@endif
These are the mount and render methods
public $preference;
public $skills;
public function mount($preference) {
$this->preference = $preference;
$this->skills = Auth()->user()->mySearches;
}
public function render() {
return view('livewire.preferences');
}