Biscoff Frappe
Elite
How to show all the softdeleted table rows in a modal using laravel?
withTrashed() method on your model.<!-- Your button to open the modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#softDeletedRowsModal">
Open Modal
</button>
<!-- Your modal -->
<div class="modal" id="softDeletedRowsModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Soft Deleted Rows</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Deleted At</th>
</tr>
</thead>
<tbody>
@foreach($softDeletedRows as $row)
<tr>
<td>{{ $row->id }}</td>
<td>{{ $row->name }}</td>
<td>{{ $row->deleted_at }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
public function showSoftDeletedRowsInModal()
{
$softDeletedRows = YourModel::withTrashed()->get();
return view('your-view-file', compact('softDeletedRows'));
}
YourModel with your actual model name and 'your-view-file' with your view file name.