DataFeed

Model Data Feed class.

 class Winter\Storm\Database\DataFeed

Combine various models in to a single feed.

Properties

public $limitCount : int

Limits the number of results.

public $limitOffset : int

Set the limit offset.

public $removeDuplicates : bool

public $sortDirection : string

Default sorting direction.

public $sortField : string

Default sorting attribute.

public $sortVar : string

An alias to use for each entries timestamp attribute.

public $tagVar : string

The attribute to use for each model tag name.

protected $collection : array

Model collection pre-query.

protected $queryCache : Winter\Storm\Database\Builder | null

Cache containing the generic collection union query.

Methods

public add (string $tag, Closure | EloquentModel | mixed $item, string | null $orderBy = null) : DataFeed | void

Add a new Builder to the feed collection

Parameters
Property Description
$tag
string
$item
Closure | EloquentModel | mixed
$orderBy
string | null
Returns
DataFeed | void

public count () : integer

Count the number of results from the generic union query

Returns
integer

public get () : Collection

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

Returns
Collection

public limit (int $count, int | null $offset = null) : DataFeed

Limits the number of results displayed.

Parameters
Property Description
$count
int
$offset
int | null
Returns
DataFeed

public orderBy (string $field, string $direction = null) : DataFeed

Sets the default sorting field and direction.

Parameters
Property Description
$field
string
$direction
string
Returns
DataFeed

public toSql () : string

Returns the SQL expression used in the generic union

Returns
string

protected getDataByTag (string $tag) : array

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

Parameters
Property Description
$tag
string
Returns
array

protected getKeyNameByTag (string $tag) : string | null

Returns a model key name by its tag name.

Parameters
Property Description
$tag
string
Returns
string | null

protected getModelByTag (string $tag) : EloquentModel | mixed | null

Returns a prepared model by its tag name.

Parameters
Property Description
$tag
string
Returns
EloquentModel | mixed | null

protected processCollection () : Builder

Creates a generic union query of each added collection

Returns
Builder
Copyright © 2024 Winter CMS