Delete Multiple Records Using Checkbox in Laravel

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • In this tutorial, how to implement the functionality of deleting multiple records using checkboxes in Laravel application. We'll cover the steps to add checkboxes to view and send an AJAX request to delete the selected records.
    Other tutorials: -
    1) Add Or Remove Multiple Input Fields In Laravel
    • Add Or Remove Multiple...
    2) How To Create Captcha In Laravel
    • How To Create Captcha ...
    3) Select2 for multiple select & live search
    • Select2 for multiple s...
    4) Multi-Step Form in Laravel
    • Multi-Step Form in Lar...
    5) Laravel Localization
    • Laravel Localization
    6) Laravel JavaScript Client-side Form Validation
    • Laravel JavaScript Cli...
    7) Live search in laravel
    • Live search in laravel
    8) Compress Image In Laravel
    • Compress Image In Laravel
    9) Text On Image In Laravel
    • Text On Image In Laravel
    10) Date Filters in Laravel 10
    • Date Filters in Larave...
    11) Create Zip File And Download In Laravel
    • Create Zip File And Do...
    12) User Online Or Offline Status In Laravel
    • User Online Or Offline...
    13) CRUD System For Cookies With Dark And Light Theme Example In Laravel
    • CRUD System For Cookie...
    #laravel #multipleRecordsDelete #multipleRowsDelete

КОМЕНТАРІ • 16

  • @dickvigaristag27
    @dickvigaristag27 Рік тому +2

    Worked perfectly.. How to return with sweet alert?
    alert()->success('successfully deleted user!');
    return response()->json(); but it only appears when you refresh the page

    • @BluebirdTech
      @BluebirdTech  Рік тому +1

      Here's an example to display the SweetAlert message:
      // in your Controller.php
      return response()->json([
      'success' => true,
      'message' => 'Successfully deleted user(s)!'
      ]);
      // in your script tag
      $.ajax({
      url:"{{ route('employee.delete') }}",
      type:"DELETE",
      data:{
      ids:all_ids,
      _token:'{{ csrf_token() }}'
      },
      success:function(response){
      if (response.success) {
      Swal.fire({
      icon: 'success',
      title: 'Success',
      text: response.message
      });
      // location.reload();
      }
      else {
      Swal.fire({
      icon: 'error',
      title: 'Error',
      text: 'Failed to delete user(s)!'
      });
      }
      }
      });

  • @ИванДемчишин-т7ь

    Really useful stuff. Thank you

  • @kaiserdianalan7059
    @kaiserdianalan7059 7 місяців тому

    Very useful i hope you create another for laravel 11 hehe

  • @telephonicainc7900
    @telephonicainc7900 Рік тому +1

    Thank you for your great video , it also would be nice if you add the code in each step (in text description )

    • @BluebirdTech
      @BluebirdTech  Рік тому +1

      Thanks for the suggestion. I'll add chapter descriptions to my videos to make them more accessible.

    • @telephonicainc7900
      @telephonicainc7900 Рік тому +1

      @@BluebirdTech thank you , I used your code to manage a user table like your employee table . when I click on delete selected users , the page shows me the table with selected users checked .In route command in web.php , it cannot recognize the path /selected-users ( an error 500 in inspect page) . however when I refresh the page , it shows me the updated list ( no more selected and deleted users in list) and error message goes away. I appreciate if you can advise me to resolve the issue .

    • @BluebirdTech
      @BluebirdTech  Рік тому

      @@telephonicainc7900
      It seems like there might be an issue with the route in web.php not being recognized. Here are some troubleshooting steps you can follow to resolve the issue:
      - Check the syntax of the route in web.php to make sure it matches the controller method you are trying to call. Make sure the route name and controller method name are spelled correctly and that they are using the correct HTTP method (in this case, POST).
      - Double-check the URL in the AJAX request in your JavaScript code to make sure it matches the route name in web.php.
      - Make sure the route is defined before it is used in the JavaScript code.
      - Try clearing the Laravel cache using the “php artisan cache:clear” command.

  • @harryawanda9310
    @harryawanda9310 Рік тому

    I got an error while using datatable. The data actually removed from db but the Datatable is still counting the deleted data. And when I checked the "select all" checkbox, the deleted data is displayed in my datatable. I need to refresh page manually (F5) to refresh datatable. May you can help me to resolve this. Thank you

  • @mariomartinavilayarleque7509
    @mariomartinavilayarleque7509 Місяць тому

    and paginate?

  • @Khudayberdiyev-gs9mn
    @Khudayberdiyev-gs9mn Рік тому

    good

  • @zafererkan7070
    @zafererkan7070 Рік тому

    thank you for the video. but not delete from db.

  • @dhaivatjagtap6013
    @dhaivatjagtap6013 6 місяців тому

    plz share project as a zip file