public static function last($filters = null, $fields = null)
    {
        $model = new static();

        if (is_string($primaryKey = $model->getPrimaryKey())) {
            $options['order'] = [$primaryKey => SORT_DESC];
        } else {
            throw new BadMethodCallException('infer `:class` order condition for last failed:', ['class' => static::class]);
        }

        $rs = static::query(null, $model)->select($fields)->where($filters)->limit(1)->fetch();
        return isset($rs[0]) ? $rs[0] : null;
    }
public static function last($filters = null, $fields = null)
    {
        $model = new static();

        if (is_string($primaryKey = $model->getPrimaryKey())) {
            $options['order'] = [$primaryKey => SORT_DESC];
        } else {
            throw new BadMethodCallException('infer `:class` order condition for last failed:', ['class' => static::class]);
        }

        $rs = static::query(null, $model)->select($fields)->where($filters)->limit(1)->fetch();
        return isset($rs[0]) ? $rs[0] : null;
    }
public static function last ( $ filters = null , $ fields = null ) { $ model = new static ( ) ; if ( is_string ( $ primaryKey = $ model -> getPrimaryKey ( ) ) ) { $ options [ 'order' ] = [ $ primaryKey => SORT_DESC ] ; } else { throw new BadMethodCallException ( 'infer `:class` order condition for last failed:' , [ 'class' => static :: class ] ) ; } $ rs = static :: query ( null , $ model ) -> select ( $ fields ) -> where ( $ filters ) -> limit ( 1 ) -> fetch ( ) ; return isset ( $ rs [ 0 ] ) ? $ rs [ 0 ] : null ; }
Allows to query the last record that match the specified conditions

@param array $filters =static::sample()
@param array $fields =static::sample()

@return static|null
Allows to query the last record that match the specified conditions