//index controller ->addColumn('enroll', function ($row) { if ($row->enroll == false) { return '<a href="javascript:void(0)" data-toggle="toggle" data-id="' . $row->id . '" title="Change Enroll" class="toggle-class"><i class="fa fa-exclamation-circle text-dark"></i></a>'; } if ($row->enroll == true) { return '<a href="javascript:void(0)" data-toggle="toggle" data-id="' . $row->id . '" title="Change Status" class=""><i class="far fa-check-circle text-success"></i></a>'; } }) //index blade $('body').on('click', '.toggle-class', function(e) { e.preventDefault(); var enroll = $(this).prop('checked') == false ? 0 : 1; var admission_id = $(this).data('id'); swal({ title: "Are you sure?", text: "You won't be able to revert this!", icon: "warning", showCancelButton: true, buttons: { confirm: { text: "Yes, delete it!", value: true, visible: true, className: "btn btn-primary", closeModal: true, }, cancel: { text: "Cancel", value: null, visible: true, className: "btn btn-light", closeModal: true, } } }).then((changeStatus) => { if (changeStatus) { $.ajax({ type: "GET", url: "/students/changeEnroll", data: { 'enroll': enroll, 'admission_id': admission_id }, dataType: "json", success: function(data) { dataTable.ajax.reload(); showSuccessToastUpdate(); }, error: function(data) { console.log('Error:', data); } }); } }); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter