Reputation: 1
** I need to show pagination when show data this is my controller** I try to show pagination with laravel but it is not work How I can solve this proplem ??I try to show pagination with laravel but it is not work How I can solve this proplem ??
public function showJobApplicant(Request $request)
{
$job = Job::findOrFail($request->id);
$applicants = DB::table('applicant')
->select('*')
->join('job_app', 'applicant.id', '=', 'job_app.applicant_oid')
->where('job_app.job_oid', $request->id)->paginate(2);
return response()->json([
'applicants' => $applicants,
]);
}
and this is javascript part
<script>
$('#search3').on('keyup', function(){
$('#form3').submit(false);
search3();
});
search3();
function search3(){
var keyword3 = $('#search3').val();
$.post('{{ route("showJobApplicant") }}',
{
_token: $('meta[name="csrf-token"]').attr('content'),
keyword3:keyword3,
id: {{$job->id}}
},
function(data){
table_post_row3(data);
});
}
// table row with ajax
function table_post_row3(res){
let htmlView = '';
if(res.applicants.length <= 0){
htmlView+= `
<tr>
<td colspan="9" class="text-center">لا يوجد بيانات لعرضها</td>
</tr>`;
}
var color = 'primary';
var status = 'تحت الدراسة';
<?php $check = false;
echo $check;
?>
for(let i = 0; i < res.applicants.length; i++){
var sex = 'أنثى';
if(res.applicants[i].sex == 101)
sex = 'ذكر';
var url = 'showApplicantInfo/'+ res.applicants[i].id_num;
htmlView += `
<tr>
<td>`+ (i+1) +`</td>
<td>`+res.applicants[i].f_name+' '+res.applicants[i].m_name+ ' '+ res.applicants[i].s_name+' '+res.applicants[i].l_name+`</td>
<td>`+res.applicants[i].id_num+`</td>
<td>`+res.applicants[i].bdate.split(" ")[0]+`</td>
<td>`+sex+`</td>
<td>`+res.applicants[i].mobile_num+`</td>
</tr>`;
}
$('#applicants').html(htmlView);
}
</script>
and view like this
<div class="col-12 table-responsive" id="kt_apps_projects_2">
<div class="col-md-6">
<form id="form3" method="POST">
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="البحث برقم الهوية" id="search3">
<div class="input-group-prepend">
<span class="input-group-text" >
<i class="flaticon-search-1"></i>
</span>
</div>
</div>
</form>
</div>
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th scope="col" class="text-success">#</th>
<th scope="col" class="text-success">الاسم الرباعي</th>
<th scope="col" class="text-success">رقم الهوية</th>
<th scope="col" class="text-success">تاريخ الميلاد</th>
<th scope="col" class="text-success">الجنس</th>
<th scope="col" class="text-success">رقم الجوال</th>
<th scope="col" class="text-success">الحالة</th>
<th scope="col" class="text-success">عرض التفاصيل</th>
</tr>
</thead>
<tbody id="applicants">
</tbody>
</table>
</div>
</div>
how can I show pagination, please??
answer me on this problem
Upvotes: 0
Views: 68