
<?php $__env->startSection('title','Pesan'); ?>
<?php $__env->startSection('main'); ?>

<div class="main">
	<h2><strong>Pesan</strong></h2>
	<hr>
	<br>
	<div class="data-content">
		<div class=table-control>
			<table class="table table-home table-striped table-bordered" id="pesan-table">
				<thead>
					<tr>
						<th>Nama</th>
						<th>Email</th>
						<th>Messasge</th>
						<th>Aksi</th>
					</tr>
				</thead>
				<tbody>
					
				</tbody>
			</table>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script type="text/javascript">

    $(function(){
	    $('#pesan-table').DataTable({
	      	processing : true,
	      	serverSide : true,
	      	responsive : true,
	      	ajax: "<?php echo e(route('pesanjson')); ?>",
	      	columns: [
		        {data: 'nama', name: 'nama'},
		        {data: 'email', name: 'email'},
		        {data: 'message', name: 'message'},
		        {data: 'aksi', name: 'aksi'}
	        ]
	    });
  	});

  	$(document).on('click', '.hapus', function(){
      	let id = $(this).attr('id');
      	$.ajax({
        	url : "<?php echo e(route('pesandelete')); ?>",
        	type : 'post',
        	data : {
          		id : id,
          		'_token' : "<?php echo e(csrf_token()); ?>"
        	},
        	success: function(params){
	          	alert(params.text);
	          	window.location = "<?php echo e(route('pesan')); ?>"
	        },
        	error: function(xhr){
          		alert(xhr)
        	}
      	});
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('template.template', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\rezabackend\resources\views/admin/pesan.blade.php ENDPATH**/ ?>