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

<div class="main">
	<h2><strong>Blog</strong></h2>
	<hr>
	<a href="<?php echo e(route('blogadd')); ?>" class="btn black mt-2">Tambah Data</a>
	<br><br>
	<div class="data-content">
		<div class=table-control>
			<table class="table table-home table-striped table-bordered" id="blog-table">
				<thead>
					<tr>
						<th>Featured Image</th>
						<th>Judul</th>
						<th>Author</th>
						<th>Suka</th>
						<th>Aksi</th>
					</tr>
				</thead>
				<tbody>
					
				</tbody>
			</table>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
	<script type="text/javascript">
		$(function(){
		    $('#blog-table').DataTable({
		      	processing : true,
		      	serverSide : true,
		      	responsive : true,
		      	ajax: "<?php echo e(route('blogjson')); ?>",
		      	columns: [
			        {data: 'image', name: 'image'},
			        {data: 'judul', name: 'judul'},
			        {data: 'author', name: 'author'},
			        {data: 'suka', name: 'suka'},
			        {data: 'aksi', name: 'aksi'}
		        ]
		    });
	  	});

	  	$(document).on('click', '.hapus', function(){
	      	let id = $(this).attr('id');
	      	$.ajax({
	        	url : "<?php echo e(route('blogdelete')); ?>",
	        	type : 'post',
	        	data : {
	          		id : id,
	          		'_token' : "<?php echo e(csrf_token()); ?>"
	        	},
	        	success: function(params){
		          	alert(params.text);
		          	window.location = "<?php echo e(route('blog')); ?>"
		        },
	        	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/blog.blade.php ENDPATH**/ ?>