-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination with Twig and Eloquent 5.3 #168
Comments
Hi, could you solve the problem? I have the same one: PHP Fatal error: Call to a member function make() on null in /Users/riggi/PhpstormProjects/vivida/vendor/illuminate/pagination/LengthAwarePaginator.php on line 140 seems like static::viewFactory() returns null |
Yes @Riggi basically I i replaced the links function with a custom pagination |
@Riggi here is my temporary solution $function = new Twig_SimpleFunction("render", function ($object) {
$html = '';
$data = array(); // start out array
$data['pages'] = ceil($object->total() / $object->perPage()); // calc pages
$data['si'] = ($object->currentPage() * $object->perPage()) - $object->perPage(); // what row to start at
$data['curr_page'] = $object->currentPage(); // Whats the current page
$max = 7;
if ($data['curr_page'] < $max) {
$sp = 1;
} elseif ($data['curr_page'] >= ($data['pages'] - floor($max / 2))) {
$sp = $data['pages'] - $max + 1;
} elseif ($data['curr_page'] >= $max) {
$sp = $data['curr_page'] - floor($max / 2);
}
if ($data['curr_page'] > $max) {
$html .= '<li ><a href="' . $object->url(1) . '">First Page</a></li>';
}
for ($i = $sp; $i <= ($sp + $max - 1); $i++) {
if ($i > $data['pages']) {
continue;
}
if ($object->currentPage() == $i) {
$html .= ' <li class="active">';
} else {
$html .= '<li >';
}
$html .= ' <a href="' . $object->url($i) . '">' . $i . '</a>
</li>';
}
if ($data['curr_page'] < ($data['pages'] - floor($max / 2))) {
$html .= '<li ><a href="' . $object->url($object->lastPage()) . '">Last Page</a></li>';
}
return $html;
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does anyone tried to use the Eloquent 5.3 pagination with Twig?
I'm getting the following error message
Fatal error: Uncaught Error: Call to a member function make() on null in /Applications/XAMPP/xamppfiles/htdocs/****/public_html/wp-content/plugins/crm/vendor/illuminate/pagination/LengthAwarePaginator.php:140 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/****/public_html/wp-content/plugins/crm/app/Providers/CMSServiceProvider.php(116): Illuminate\Pagination\LengthAwarePaginator->render() #1 /Applications/XAMPP/xamppfiles/htdocs/****/public_html/wp-content/twig-cache/18/189d0df44f1fe623fdad2b6fb631c15897dda3614de070c872657111c85f5f1a.php(333): Herbert\Framework\Application->{closure}(Object(Illuminate\Pagination\LengthAwarePaginator)) #2 /Applications/XAMPP/xamppfiles/htdocs/****/public_html/wp-content/plugins/properties-integration/vendor/twig/twig/lib/Twig/Template.php(438): __TwigTemplate_9d8cd83a4a6f650d70c2593b9c9d8a8b349ba241d19c1308c7f81a99c4d3f082->doDisplay(Array, Array) #3 /Applications/XAMPP/xamppfiles/htdocs/****/public_html/wp-content/plu in /Applications/XAMPP/xamppfiles/htdocs/****/public_html/wp-content/plugins/crm/vendor/illuminate/pagination/LengthAwarePaginator.php on line 140
The text was updated successfully, but these errors were encountered: