Ano kayang Problema nito Guys, Error "Only arrays and Traversables can be unpacked" . pag ni remove ko yung event.detail[0] at gawing event.detail lang, nawawala yung error pero undefined naman yung value na nakukuha ko sa section_name at section_id at hindi rin na dedelete yung data.
You do not have permission to view the full content of this post. Log in or register now.
Livewire/Section
public function ConfirmDelete($section_id, $section_name) {
$this->dispatch('SwaleletedRecord', [
'section_name' => $section_name,
'title' => 'Are You Sure You Want to Delete? <span class="text-danger">' . $section_name . '</span>',
'id' => $section_id,
]);
}
protected $listeners = ['RecordDeleted' => 'DeletedSection'];
public function RecordDeleted($section_id) {
$sectiondelete = SectionModel::find($section_id);
$sectiondelete->delete();
}
table.blade.php:
<div>
<table class="table" width="100%">
<thead>
<tr>
<th>Section Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse($sectionsdata as $section)
<tr>
<td>{{ $section->section_name }}</td>
<td>{{ $section->section_status === 1 ? 'Enabled' : 'Disabled' }}</td>
<td>
<div class="btn-group">
<a href="#editSection" data-toggle="modal" wire:click.prevent="editSection({{ $section->id }})" class="btn btn-info"><i class="fa fa-edit"></i></a>
<a href="#" wire:click.prevent="ConfirmDelete({{$section->id}}, '{{$section->section_name}}')" class="btn btn-danger"><i class="fa fa-trash"></i></a>
</div>
</td>
</tr>
@include('sections.edit')
empty
@endforelse
</tbody>
</table>
</div>
You do not have permission to view the full content of this post. Log in or register now.
Livewire/Section
public function ConfirmDelete($section_id, $section_name) {
$this->dispatch('SwaleletedRecord', [
'section_name' => $section_name,
'title' => 'Are You Sure You Want to Delete? <span class="text-danger">' . $section_name . '</span>',
'id' => $section_id,
]);
}
protected $listeners = ['RecordDeleted' => 'DeletedSection'];
public function RecordDeleted($section_id) {
$sectiondelete = SectionModel::find($section_id);
$sectiondelete->delete();
}
table.blade.php:
<div>
<table class="table" width="100%">
<thead>
<tr>
<th>Section Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse($sectionsdata as $section)
<tr>
<td>{{ $section->section_name }}</td>
<td>{{ $section->section_status === 1 ? 'Enabled' : 'Disabled' }}</td>
<td>
<div class="btn-group">
<a href="#editSection" data-toggle="modal" wire:click.prevent="editSection({{ $section->id }})" class="btn btn-info"><i class="fa fa-edit"></i></a>
<a href="#" wire:click.prevent="ConfirmDelete({{$section->id}}, '{{$section->section_name}}')" class="btn btn-danger"><i class="fa fa-trash"></i></a>
</div>
</td>
</tr>
@include('sections.edit')
empty
@endforelse
</tbody>
</table>
</div>