

<?php $__env->startSection('content'); ?>
<div class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-12 float-left">
                                <button type="button" class="btn btn-primary">
                                    <a href="<?php echo e(route('news.add')); ?>">
                                        <i class="nc-icon nc-simple-add"></i>
                                        <?php echo e(__("Tambah")); ?>

                                    </a>
                                </button>
                            </div>
                            <div class="col-md-12">
                                <?php if(session()->has('message')): ?>

                                <div class="alert alert-success alert-dismissable custom-success-box"
                                    style="margin: 15px;">
                                    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                                    <strong> <?php echo e(session()->get('message')); ?> </strong>
                                </div>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-hover" style="width:100%;" id="table_news">
                                <thead>
                                    <tr class="odd">
                                        <th>
                                            No.
                                        </th>
                                        <th>
                                            Judul
                                        </th>
                                        <th>
                                            thumbnail
                                        </th>
                                        <th>
                                            Author
                                        </th>
                                        <th>
                                            Tanggal
                                        </th>
                                        <th>
                                            Aksi
                                        </th>
                                    </tr>

                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>

<script type="text/javascript">
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    $(document).ready(function () {
        // Javascript method's body can be found in assets/js/demos.js
        getTable();

    });

    function getTable() {
        var table = $('#table_news').DataTable({
            processing: true,
            serverSide: true,
            ajax: "<?php echo e(route('news.json')); ?>",
            columns: [{
                    data: 'DT_RowIndex',
                    name: 'DT_RowIndex'
                },
                {
                    data: 'judul',
                    name: 'judul'
                },
                {
                    data: 'img',
                    name: 'img'
                },
                {
                    data: 'author',
                    name: 'author'
                },
                {
                    data: 'tgl',
                    name: 'tgl'
                },
                {
                    data: 'action',
                    name: 'action',
                    orderable: true,
                    searchable: true
                },
            ]
        });
    }

    function refresh_table() {
        $('#table_news').DataTable().ajax.reload();
    }



    function hapus(id) {
        console.log(id)
        $.ajax({
            url: "/news/delete/" + id,
            type: "get",
            // dataType: 'json',
            success: function (data) {
                // console.log(data)
                // $('#docForm').trigger("reset");
                // $('#tambahDoc').modal('hide');
                // table.draw();
                demo.notifSuccess(data.message)
                refresh_table()

            },
            error: function (data) {
                console.log('Error:', data);
                // $('#saveBtn').html('Save Changes');
            }
        });
    }

</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', ['activePage' => 'berita', 'title' => 'Berita', 'navName' => 'Berita', 'activeButton' =>
'laravel'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\DARMAWANTO skripsi\project-g\resources\views/Beritas/index.blade.php ENDPATH**/ ?>