Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete confirmation in laravel

Tags:

I have the following code:

@foreach($results as $result)
  <tr>
    <td>{{$result->my_id}}</td>
    <td>{{$result->province_name}}</td>
    <td>{{$result->city_name}}</td>
    <td>
      <a class="btn btn-primary" href="{{route('city-edit', $result->my_id)}}"><i class="fa fa-edit"></i></a>
      <a class="btn btn-danger" href="{{route('city-delete', $result->my_id)}}"><i class="fa fa-trash"></i></a>
    </td>
  </tr>
@endforeach

How to add a confirmation on delete each data?

like image 305
yudijohn Avatar asked Oct 07 '15 06:10

yudijohn


People also ask

How do I delete a record in laravel?

app/Http/routes.phpRoute::get('delete-records','StudDeleteController@index'); Route::get('delete/{id}','StudDeleteController@destroy'); Step 6 −The output will appear as shown in the following image. Step 7 − Click on delete link to delete that record from database.

How do you enable Confirm Delete in Windows 10?

On the desktop, navigate to the "Recycle Bin" folder. Right-click on the Recycle Bin folder and click on the "Properties" option. "Recycle Bin Properties" window will appear on the screen. Click (select) on the "Display delete confirmation dialog" option and click on the "Apply" button to proceed.


1 Answers

I prefer a more easier way, just add onclick="return confirm('Are you sure?')", as bellow:

<a class="btn btn-danger" onclick="return confirm('Are you sure?')" href="{{route('city-delete', $result->my_id)}}"><i class="fa fa-trash"></i></a>
like image 182
Mustafa Ehsan Alokozay Avatar answered Sep 17 '22 11:09

Mustafa Ehsan Alokozay