Landish\Pagination\Pagination::getPreviousButton PHP Method

getPreviousButton() protected method

Get the previous page pagination element.
protected getPreviousButton ( ) : string
return string
    protected function getPreviousButton()
    {
        // If the current page is less than or equal to one, it means we can't go any
        // further back in the pages, so we will render a disabled previous button
        // when that is the case. Otherwise, we will give it an active "status".
        if ($this->paginator->currentPage() <= 1) {
            return $this->getDisabledTextWrapper($this->getPreviousButtonText());
        }
        $url = $this->paginator->url($this->paginator->currentPage() - 1);
        return $this->getPageLinkWrapper($url, $this->getPreviousButtonText());
    }

Usage Example

Example #1
0
 protected function getPreviousButton()
 {
     $replacements = ['disabled' => 'disabled prev', '<li>' => '<li class="prev">', 'span' => 'a'];
     return str_replace(array_keys($replacements), array_values($replacements), parent::getPreviousButton());
 }