Unable to go last page and antepenultimate of the bootstrap laravel pagination - laravel

Before I create one laravel 8 application and I was using the bootstrap pagination, but I was getting about 40 rows from my database and the pagination works fine, but now I created another application and now I have 300020 rows in my database and now the pagination is bigger than before, but the problem is that if try to go to the last page as we can see in the picture below I can't do it, I only can go to a minor page than it.
I don't know why the pagination can't agree me go to the last page and antepenultimate.
I'm using the links() method.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employees</title>
<link href="{{ mix('css/app.css') }}" rel="stylesheet" type="text/css" />
</head>
<body>
{{ $employees->total() }}
<div class="container">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<table class="table">
<thead class="thead-dark">
<th>Emp_no</th>
<th>First Name</th>
<th>Last Name</th>
<th>Hire Date</th>
</thead>
<tbody>
#foreach($employees as $employee)
<tr>
<td>{{ $employee->emp_no }}</td>
<td>{{ $employee->first_name }}</td>
<td>{{ $employee->last_name }}</td>
<td>{{ $employee->hire_date }}</td>
</tr>
#endforeach
</tbody>
</table>
<hr>
{{ $employees->links() }}
</div>
<div class="col-sm-4"></div>
</div>
</div>
<!-- Bootstrap JS, jquery y popper compiled -->
<script src="{{ mix('js/app.js') }}" type="text/javascript"></script>
</body>
</html>
Here is my code from the controller:
class EmployeeController extends Controller
{
public function index() {
$employees = Employee::query()->Paginate(5);
return view('employee.index', compact('employees'));
}
}
My model code, I import a table to my database:
class Employee extends Model
{
use HasFactory;
protected $table = 'employees';
protected $primaryKey = 'emp_no';
}
I like test my apps when there will be thousands of data. Well guy if you have any idea about how fix this problem, I will appreciate it. thanks.

The problem was with the html due to the lack of space in the central div. Then I updated my code and now I only have one column:
<div class="container">
<div class="row">
<div class="col-md-12">
<table class="table table-hover">
<thead class="thead-dark">
<th>Emp_no</th>
<th>First Name</th>
<th>Last Name</th>
<th>Hire Date</th>
</thead>
<tbody>
#foreach($employees as $employee)
<tr>
<td>{{ $employee->emp_no }}</td>
<td>{{ $employee->first_name }}</td>
<td>{{ $employee->last_name }}</td>
<td>{{ $employee->hire_date }}</td>
</tr>
#endforeach
</tbody>
</table>
<hr>
{{ $employees->links() }}
</div>
</div>
</div>

Related

i want to get Instagram profile total followers and following and post get this error 429 Too Many Requests on laravel

I want to get Instagram profile total followers and following and post get this error" 429 Too Many Requests on Laravel.
I need for it to show my users profile information on their account page on my website. I tried it, but I didn't get the profile json data.
Here I send my route view and controller.
1. routes/web.php
Route::get('instagram', 'InstagramController#index');
2. app/Http/Controllers/InstagramController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class InstagramController extends Controller {
/**
* Get the index name for the model.
*
* #return string
*/
public function index(Request $request) {
$items = [];
if($request->has('username')){
$client = new \GuzzleHttp\Client;
$url = sprintf('https://www.instagram.com/%s/media', $request->input('username'));
$response = $client->get($url);
$items = json_decode((string) $response->getBody(), true)['items'];
}
return view('instagram',compact('items'));
}
}
3. resources/views/instagram.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Laravel 5 Instagram API tutorial with example</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h2>Laravel 5 Instagram API tutorial with example</h2><br/>
<form method="GET" role="form">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" id="username" name="username" class="form-control" placeholder="Enter Instagram Username" value="{{ old('username') }}">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<button class="btn btn-success">Search</button>
</div>
</div>
</div>
</form>
<div class="panel panel-primary">
<div class="panel-heading">Instagram Feed</div>
<div class="panel-body">
<table class="table table-bordered">
<thead>
<th>No</th>
<th width="200px;">Id</th>
<th>Code</th>
<th>Image</th>
<th>Location</th>
<th>Total Likes</th>
<th>Total Comments</th>
</thead>
<tbody>
#if(!empty($items))
#foreach($items as $key => $item)
<tr>
<td>{{ ++$key }}</td>
<td>{{ $item['id'] }}</td>
<td>{{ $item['code'] }}</td>
<td><img src="{{ $item['images']['standard_resolution']['url'] }}" style="width:100px;"></td>
<td>{{ isset($item['location']['name']) ? $item['location']['name'] : '' }}</td>
<td>{{ $item['likes']['count'] }}</td>
<td>{{ $item['comments']['count'] }}</td>
</tr>
#endforeach
#else
<tr>
<td colspan="4">There are no data.</td>
</tr>
#endif
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>

How to solve design break when use page-break in dompdf

When generating the pdf with page-break-before after 3rd rows the design is breaking down. Here is my code
<!DOCTYPE html>
<html lang="en">
<head>
<title>DOM-PDF</title>
</head>
<body>
<table style="width:100%;">
<thead>
<tr>
<th>Serial</th>
<th>Name</th>
<th>Roll</th>
<th>Info</th>
</tr>
</thead>
<tbody>
#php
$n = 0;
for($i=0;$i<10;$i++){
#endphp
<tr style="text-align:center;">
<td>1</td>
<td>Rashedul Hasan</td>
<td>1208039</td>
<td>I am an employee.</td>
</tr>
#php
if($n==3){
echo "<i style='page-break-before:always;'></i> ";
}
$n++;
}
#endphp
</tbody>
</table>
</body>
</html>
This is the pdf view of page 1
This is the pdf view of page 2
In page 2 second row is moving to the right. How to fix it?
What about using chunks instead of breaking the table?
{{-- Replace collect()->times(10) with a collection when you're getting the actual data from DB --}}
#foreach (collect()->times(10)->chunk(3) as $chunk)
<table style="width:100%;">
<thead>
<tr>
<th>Serial</th>
<th>Name</th>
<th>Roll</th>
<th>Info</th>
</tr>
</thead>
<tbody>
#foreach($chunk as $result)
<tr style="text-align:center;">
<td>{{ $result }}</td>
<td>Rashedul Hasan</td>
<td>1208039</td>
<td>I am an employee.</td>
</tr>
#endforeach
</tbody>
</table>
<i style='page-break-before:always;'></i>
#endforeach

Datatable not showing properly in the laravel blade file

I'm getting one issue in the datable. I added datatable in my laravel blade file, but when I clicked on the menu (call blade file). Then it shows a normal table, but when I refresh the same page again and then it shows datatable properly. My question is when I click on the menu(call blade file), then why it is not showing datatable properly. It shows a normal table only. How to fix this.
please check imagesthis image is before refresh
this image is after refresh
and this is my blade file
#extends('backEnd.layout')
<!--page level css starts-->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css">
<!--end of page level css-->
#section('content')
<div class="padding">
<div class="box">
<div class="box-header dker">
<h3>Product List</h3>
<small>
{{ trans('backLang.home') }} /
Product List
</small>
</div>
<table class="table table-bordered" id="table" >
<thead class=" primary">
<tr >
<th class="text-center">Category</th>
<th class="text-center">Title</th>
<th class="text-center">Make</th>
<th class="text-center">Rate</th>
<th class="text-center">Status</th>
</tr>
</thead>
<tbody>
#foreach($records as $record)
<tr>
<td class="text-center">{{$record->section_title}}</td>
<td class="text-center">{{$record->title_en}}</td>
<td class="text-center">{{$record->make}}</td>
<td class="text-center">{{$record->rate}}</td>
<td class="text-center">#if($record->status != 1) Used
#else New #endif
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
#endsection
#section('footerInclude')
<script type="text/javascript">
$("#checkAll").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);
});
$("#action").change(function () {
if (this.value == "delete") {
$("#submit_all").css("display", "none");
$("#submit_show_msg").css("display", "inline-block");
} else {
$("#submit_all").css("display", "inline-block");
$("#submit_show_msg").css("display", "none");
}
});
</script>
<script>
$(document).ready(function() {
$('#table').DataTable();
} );
</script>
<script src="//code.jquery.com/jquery-1.12.3.js"></script>
<script src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
#endsection
any help will be appreciated.
Thanks in advance.
Your Blade file should be like this.
You should add script files before you write your script.
#extends('backEnd.layout')
<!--page level css starts-->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css">
<!--end of page level css-->
#section('content')
<div class="padding">
<div class="box">
<div class="box-header dker">
<h3>Product List</h3>
<small>
{{ trans('backLang.home') }} /
Product List
</small>
</div>
<table class="table table-bordered" id="table" >
<thead class=" primary">
<tr >
<th class="text-center">Category</th>
<th class="text-center">Title</th>
<th class="text-center">Make</th>
<th class="text-center">Rate</th>
<th class="text-center">Status</th>
</tr>
</thead>
<tbody>
#foreach($records as $record)
<tr>
<td class="text-center">{{$record->section_title}}</td>
<td class="text-center">{{$record->title_en}}</td>
<td class="text-center">{{$record->make}}</td>
<td class="text-center">{{$record->rate}}</td>
<td class="text-center">#if($record->status != 1) Used
#else New #endif
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
<script src="//code.jquery.com/jquery-1.12.3.js"></script>
<script src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#table').DataTable();
$("#checkAll").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);
});
$("#action").change(function () {
if (this.value == "delete") {
$("#submit_all").css("display", "none");
$("#submit_show_msg").css("display", "inline-block");
} else {
$("#submit_all").css("display", "inline-block");
$("#submit_show_msg").css("display", "none");
}
});
} ;
</script>
#section('footerInclude')
#endsection

Why syntax error, unexpected 'endforeach' (T_ENDFOREACH) in Laravel 5.3?

i have created a view form blade template for showing database data. Now running the script showing fatal error for foreach loop when i ending foreach loop by #endforeach, what will be the solution
<!DOCTYPE html>
<html>
<head>
<title>All userinfo</title>
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row col-md-6 col-md-offset-2 custyle">
<table class="table table-striped custab">
<thead>
<b>+</b> Add new categories
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Age</th>
<th>Hometown</th>
<th class="text-center">Action</th>
</tr>
</thead>
foreach($alldata as $data)
<tr>
<td>{{ $data -> id }}</td>
<td>{{ $data -> name }}</td>
<td>{{ $data -> email }}</td>
<td>{{ $data -> age }}</td>
<td>{{ $data -> hometown }}</td>
<td class="text-center"><a class='btn btn-info btn-xs' href="#"><span class="glyphicon glyphicon-edit"></span> Edit</a> <span class="glyphicon glyphicon-remove"></span> Del</td>
</tr>
#endforeach
</table>
</div>
</div>
</body>
</html>
Here you forgot about #:
#foreach($alldata as $data)

Dompdf output contains weird borders

I'm currently trying to convert a HTML file into PDF file using DOMPDF. However the converted pdf files contains these red and yellow borders. Is there any way to remove these borders?
Part of my html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--<link rel="stylesheet" href="<?php echo base_url('styles/CPP.css')?>" type="text/css" />-->
</head>
<body>
<div id="header">
<div id="logo">
<!--<img src="<?php echo base_url('styles/logo.gif')?>"/>-->
</div>
<div id="version-date">
<p>Version date: 26 Aug 2015</p>
</div>
<div id="form-title">
<p><i>Research and Consultancy Office</i></p>
<p>Graduate Studies and Research Education</p>
<p style="font-size: 25px"><strong>Conference Participation Proposal</strong></p>
</div>
</div>
<div id="info">
<p>This form will be used by Coordinating Supervisors to recommend their research students for
conference participation. File Naming Instruction for 2015. For an applicant associated with the
FECS Faculty, intending to participate in the conference CONF2015, please save the form with a
file name like this: <strong>2015</strong> FECS <strong>Student Name (</strong>CONF2015 <strong>
Participation Proposal).docx</strong></p>
</div>
<div id="form-content">
<!--<table border="1">-->
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<th class="table-title" colspan="4">STUDENT DETAILS</th>
</tr>
<tr>
<td class="align-right">Student ID</td>
<td></td>
<td class="align-right-a">Student Name</td>
<td></td>
</tr>
<tr>
<td class="align-right">Course (MBus/MSc/PhD)</td>
<td></td>
<td class="align-right-a">Date of Enrolment</td>
<td></td>
</tr>
<tr>
<td class="align-right">Research Focus or Topic</td>
<td colspan="3"></td>
</tr>
<tr>
<td class="align-right">Coordinating Supervisor</td>
<td colspan="3"></td>
</tr>
</table>
My controller:
class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('url');
require_once(APPPATH.'third_party/dompdf/dompdf_config.inc.php');
}
public function index()
{
$dompdf = new DOMPDF();
$data = "123";
$html = $this->load->view('CPP_form/Conference_Participation_Proposal.html',$data,true);
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream('CPP_Form.pdf',array('Attachment'=>0));
//$this->load->view('CPP_form/Conference_Participation_Proposal.html');
}
}
You seem to have put DOMPDF_DEBUG_LAYOUT constants to true in dompdf.config.php

Resources