Bolt\Legacy\Content::previous PHP Method

previous() public method

Get the previous record. In this case 'previous' is defined as 'latest one published before this one' by default. You can pass a parameter like 'id' or '-title' to use that as the column to sort on.
public previous ( string $field = 'datepublish', array $where = [] ) : Content
$field string
$where array
return Content
    public function previous($field = 'datepublish', $where = [])
    {
        list($field, $asc) = $this->app['storage']->getSortOrder($field);
        $operator = $asc ? '<' : '>';
        $order = $asc ? ' DESC' : ' ASC';
        $params = [$field => $operator . $this->values[$field], 'limit' => 1, 'order' => $field . $order, 'returnsingle' => true, 'hydrate' => true];
        $pager = [];
        $previous = $this->app['storage']->getContent($this->contenttype['singular_slug'], $params, $pager, $where);
        return $previous;
    }