protected function getFromSession($key, $perPage)
    {
        $session = $this->request->session();
        if (!$session->has($key) or $this->request->ajax()) {
            $session->put($key, $perPage);
            $session->save();
        }
        return $session->get($key);
    }