Mehrfach überprüft in Laravel8 löschen
//web.php
Route::post('/contact-bulk-action',[ContactController::class,'bulkAction'])->name('contact.bulkAction');
//_Controller.php
public function bulkAction(\Illuminate\Http\Request $request){
Contact::destroy($request->contact_ids);
return redirect()->back();
}
//_.blade.php
<form action="{{route('contact.bulkAction')}}" id="bulk_action" method="post">
@csrf
</form>
<ul class="list-group">
@forelse($contacts as $contact)
<li class="list-group-item d-flex justify-content-between align-items-center">
<div class="">
<div class="form-check">
<input type="checkbox" form="bulk_action" name="contact_ids[]" value="{{$contact->id}}" id="contact{{ $contact->id }}">
<label for="contact{{ $contact->id }}">
{{$contact->name}}
</label>
</div>
</div>
</li>
@empty
<li>
There is no data
</li>
@endforelse
</ul>
WinMaw