I have an inconvenience that when the user wants to delete a post it is deleted without further ado, but I want to ask the user some confirmation if he wants to delete it, I am working with php, eloquent, twige illuminate, for now I have this part in the controller of the get which happened a parameter that is the (id) of the post that is going to be deleted.
In this first part I have the administration index, from here I send the get for the elimination of post to the controller
{% extends "layout.twig" %}
{% block content %}
<a class="btn btn-primary" style="margin-bottom: 10px" href="{{ 'admin/posts' | url }}">Back</a>
<form action="{{ 'admin/posts/update' | url }}" method="post">
{% if errors %}
{% include ('partials/errors.twig') %}
{% endif %}
{% if result %}
<div class="alert alert-success">
Success!!!
</div>
{% endif %}
<div class="form-group">
<h2>{{ blogPost.title }}</h2>
</div>
<div class="form-group">
<label for="inputImg">Image</label>
<input class="form-control" type="text" name="img" id="inputImg" value="{{ blogPost.img_url }}">
</div>
<input type="hidden" name="id" value="{{ blogPost.id }}">
<div class="form-group">
<label for="inputContent">Content</label>
<textarea class="form-control" name="content" id="inputContent" rows="10">{{ blogPost.content }}</textarea>
</div>
<div class="form-group">
<input class="btn btn-primary" style="margin-top: 10px" type="submit" value="Save">
</div>
</form>
{% endblock %}
Here I have the controller which receives the parameter of the id to be deleted
public function getDelete($id){
BlogPost::destroy($id);
header('Location:' . BASE_URL . 'admin/posts');
}
what I want to implement the confirmation is an anchor, delete:
<tbody>
{% for blogPost in blogPosts %}
<tr>
<td>{{ blogPost.title }}</td>
<td><a class="btn btn-warning" href="{{ "admin/posts/update/" | url }}{{ blogPost.id }}">Edit</a></td>
<td><a class="btn btn-danger" href="{{ 'admin/posts/delete/' | url }}{{ blogPost.id }}">Delete</a></td>
</tr>
{% endfor %}
</tbody>