user-dashboard.blade.
php file
{{-- spinner loader before datatable load by hemant --}}
<div id="datatable-loader" class="text-center py-4"
style="display:none;">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<div>Processing...</div>
</div>
{{-- end spinner loader --}}
{{-- start datatable here by hemant --}}
<div class="col-12 mt-3">
<table class="table dt-responsive nowrap w-100"
id="reportTable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Mobile</th>
<th>Approved Time</th>
<th>Profile Type</th>
</tr>
</thead>
</table>
</div>
{{-- end datatable here --}}
<script>
// Show loader, hide table temporarily
$('#datatable-loader').show();
$('#reportTable').hide();
//ajax function code below
// Destroy old table if exists
if ($.fn.DataTable.isDataTable('#reportTable')) {
$('#reportTable').DataTable().destroy();
}
// Initialize DataTable
$('#reportTable').DataTable({
data: caste_Response[5],
responsive: true,
pageLength: 5,
lengthMenu: [5, 10, 25, 50, 100],
columns: [
{ data: 'id' },
{ data: 'name' },
{ data: 'user_mobile' },
{ data: 'is_approved_on',
render: function(data) {
return data ? data.split(' ')[0] : '';
}
},
{
data: 'matchmaker_is_profile',
render: function(data) {
return data == 1 ? 'Basic Profile' : 'Approved
Profile';
}
}
],
language: {
search: "Search:",
lengthMenu: "Show _MENU_ entries",
info: "Showing _START_ to _END_ of _TOTAL_ entries",
paginate: {
next: "Next",
previous: "Previous"
},
zeroRecords: "No matching records found"
}
});
// Hide loader and show table
$('#datatable-loader').hide();
$('#reportTable').show();
<script/>
DashboardController.php file code
//this code of $approved,$addbasic = last lines code -
>select('id','name','user_mobile','is_approved_on','matchmaker_is_profile');
$approvedProfile = $aporved->union($adbasic)->get();