protected function calculateLastPage()
    {
        if (empty($this->total)) {
            $this->lastPage = 0;
            return;
        }

        if (empty($this->perPage)) {
            throw new \RuntimeException('Cannot calculate last page. Insufficient data');
        }

        $this->lastPage = (int) ceil($this->total / $this->perPage);
    }