jeudi 4 mai 2017

Multiple Delete Using Checkbox in Laravel 5.4

I am very new with Laravel. I am creating a project with data pagination. I successfuly made the CRUD work (thanks to the tutorials) but I am stock on how to delete multiple rows selected using checkbox. I tried to search around but I cannot find a very solid answer. I only found this sample using Javascript but I'm stock on the part where the JS script passes the variable to my controller. Here is my proble and I hope someone can help me. Sorry for my bad english.

Blade Page
                        @foreach ($it_equipments as $key => $d)
                    <tr>
                        <td><input type="checkbox" class="checkitem" value=""></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>
                             <div class="btn-group">
                              <button type="button" class="btn btn-danger btn-del">Remove</button>
                                <button type="button" class="btn btn-info">View</button>
                                <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
                                <span class="caret"></span>
                                <span class="sr-only">Toggle Dropdown</span>
                                </button>
                                    <ul class="dropdown-menu" role="menu" style="padding:5px 5px 5px 5px;">
                                        <li><b>Balance/ Card Quantity:</b> </li>
                                        <li><b>Drop Quantity:</b> </li>
                                        <li><b>Drop Value:</b> </li>
                                        <li><b>Remarks:</b> </li>
                                    </ul>
                             </div>
                        </td>
                        <td>
                        <div class="btn-group">
                                <button type="button" class="glyphicon glyphicon-eye-open btn btn-success">Action</button>
                                <button type="button" class="btn btn-successs dropdown-toggle" data-toggle="dropdown">
                                <span class="caret"></span>
                                <span class="sr-only">Toggle Dropdown</span>
                                </button>
                                    <ul class="dropdown-menu" role="menu">

                                    <li><a href="">Edit</a></li>
                                    <li><a href=""  onclick="return confirm('Are you sure to delete this inventory entitled:  ?')">Delete</a></li>
                                    <li><a href=""  onclick="return confirm('Are you sure to delete all selected rows?')">Delete Selected</a></li>
                                    </ul>
                             </div>
                        </td>
                    </tr>
                    @endforeach

Script (Where I can't find where or how to connect it to my controller)

 <script>
$('#delsel').click(function()
{
    var id = $('.checkitem:checked').map(function()
    {
        return $(this).val()
    })
    .get().join(' ')
    $.post('help.php', {id: id}, function(data))
    {
        viewdata()
    })
})
</script>

`Router

Route:: `get('/postDelete_inv_selected/{id}','InvController@postDelete_inv_selected');`




Aucun commentaire:

Enregistrer un commentaire