public function paginate($n, $current = 0, $chunk = null)
    {
        // We go a page back
        --$current;

        // Variable containing the number of jump. $jump;

        if ($current <= 0) {
            $jump = 0;

            $current = 1;
        } else {
            $jump = $n * $current;
            
            $current++;
        }

        // Saving information about where
        $where = $this->where;

        $dataBind = $this->where_data_binding;

        $data = $this->jump($jump)
            ->take($n)->get();

        // Reinitialization of where
        $this->where = $where;

        $this->where_data_binding = $dataBind;

        // We count the number of pages that remain
        $restOfPage = ceil($this->count() / $n) - $current;

        // Grouped data
        if (is_int($chunk)) {
            $data = array_chunk($data, $chunk);
        }

        // Enables automatic paging.
        $data = [
            'next' => $current >= 1 && $restOfPage > 0 ? $current + 1 : false,
            'previous' => ($current - 1) <= 0 ? 1 : ($current - 1),
            'total' => (int) ($restOfPage + $current),
            'current' => $current,
            'data' => $data
        ];

        return new Collection($data);
    }
public function paginate($n, $current = 0, $chunk = null)
    {
        // We go a page back
        --$current;

        // Variable containing the number of jump. $jump;

        if ($current <= 0) {
            $jump = 0;

            $current = 1;
        } else {
            $jump = $n * $current;
            
            $current++;
        }

        // Saving information about where
        $where = $this->where;

        $dataBind = $this->where_data_binding;

        $data = $this->jump($jump)
            ->take($n)->get();

        // Reinitialization of where
        $this->where = $where;

        $this->where_data_binding = $dataBind;

        // We count the number of pages that remain
        $restOfPage = ceil($this->count() / $n) - $current;

        // Grouped data
        if (is_int($chunk)) {
            $data = array_chunk($data, $chunk);
        }

        // Enables automatic paging.
        $data = [
            'next' => $current >= 1 && $restOfPage > 0 ? $current + 1 : false,
            'previous' => ($current - 1) <= 0 ? 1 : ($current - 1),
            'total' => (int) ($restOfPage + $current),
            'current' => $current,
            'data' => $data
        ];

        return new Collection($data);
    }
public function paginate ( $ n , $ current = 0 , $ chunk = null ) { // We go a page back -- $ current ; // Variable containing the number of jump. $jump; if ( $ current <= 0 ) { $ jump = 0 ; $ current = 1 ; } else { $ jump = $ n * $ current ; $ current ++ ; } // Saving information about where $ where = $ this -> where ; $ dataBind = $ this -> where_data_binding ; $ data = $ this -> jump ( $ jump ) -> take ( $ n ) -> get ( ) ; // Reinitialization of where $ this -> where = $ where ; $ this -> where_data_binding = $ dataBind ; // We count the number of pages that remain $ restOfPage = ceil ( $ this -> count ( ) / $ n ) - $ current ; // Grouped data if ( is_int ( $ chunk ) ) { $ data = array_chunk ( $ data , $ chunk ) ; } // Enables automatic paging. $ data = [ 'next' => $ current >= 1 && $ restOfPage > 0 ? $ current + 1 : false , 'previous' => ( $ current - 1 ) <= 0 ? 1 : ( $ current - 1 ) , 'total' => ( int ) ( $ restOfPage + $ current ) , 'current' => $ current , 'data' => $ data ] ; return new Collection ( $ data ) ; }
Paginate, make pagination system

@param int $n
@param int $current
@param int $chunk

@return Collection
Paginate make pagination system