I have datatables which is render image inside table but what I've done is just if there is image then render but if no image not yet have statement
here's my datatables
<script type="text/javascript">
$(function() {
$('#pengumuman-table').DataTable({
processing: true,
serverSide: true,
responsive: true,
ajax: '{!! route('pengumuman.data') !!}',
columns: [
{ data: 'rownum', name: 'rownum' },
{ data: 'gambar', render: function(data)
{ return '<img src="{{ asset("/images/pengumuman/") }}/'+data+'" atl img style="width:200px; height:150px"/>' }
},
{ data: 'nama_pengumuman', name: 'nama_pengumuman' },
{ data: 'created_at', name: 'created_at' },
{ data: 'action', name: 'action', orderable: false, searchable: false }
]
});
});
</script>
How do I add statement if no image in datatable like this in php
@if(isset($pegawai->foto) && !empty($pegawai->foto))
<div align="center">
<img src="{{ asset("/images/karyawan/$pegawai->foto") }}" alt="" img style="width:250px; height:260px">
</div>
@else
<div align="center">
<img src="http://www.blogsaays.com/wp-content/uploads/2014/02/no-user-profile-picture-whatsapp.jpg" alt="" img style="width:250px; height:260px">
</div>
@endif