October\Rain\Database\DataFeed

Source: ~/vendor/october/rain/src/Database/DataFeed.php

Model Data Feed class.

Combine various models in to a single feed.

Public properties

public string $tagVar

The attribute to use for each model tag name.

public string $sortVar

An alias to use for each entries timestamp attribute.

public string $sortField

Default sorting attribute.

public string $sortDirection

Default sorting direction.

public string $limitCount

Limits the number of results.

public string $limitOffset

Set the limit offset.

public bool $removeDuplicates

Protected properties

protected array $collection

Model collection pre-query.

protected Builder $queryCache

Cache containing the generic collection union query.

Public methods

public void add($tag, $item, $orderBy=NULL)

Add a new Builder to the feed collection

Parameters
  • $tag
  • $item
  • $orderBy

public void count()

Count the number of results from the generic union query

public void get()

Executes the generic union query and eager loads the results in to the added models

public void limit($count, $offset=NULL)

Limits the number of results displayed.

Parameters
  • $count
  • $offset

public void orderBy($field, $direction=NULL)

Sets the default sorting field and direction.

Parameters
  • $field
  • $direction

public void toSql()

Returns the SQL expression used in the generic union

Protected methods

protected array getDataByTag($tag)

Returns a data stored about an item by its tag name.

Parameters
  • $tag

protected Model getKeyNameByTag($tag)

Returns a model key name by its tag name.

Parameters
  • $tag

protected Model getModelByTag($tag)

Returns a prepared model by its tag name.

Parameters
  • $tag

protected void processCollection()

Creates a generic union query of each added collection