Documentation

DataFeed
in package

Model Data Feed class.

Combine various models in to a single feed.

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

$limitCount  : string
$limitOffset  : string
$removeDuplicates  : bool
$sortDirection  : string
$sortField  : string
$sortVar  : string
$tagVar  : string
$collection  : array<string|int, mixed>
$queryCache  : Builder
add()  : DataFeed|void
Add a new Builder to the feed collection
count()  : int
Count the number of results from the generic union query
get()  : Collection
Executes the generic union query and eager loads the results in to the added models
limit()  : DataFeed
Limits the number of results displayed.
orderBy()  : DataFeed
Sets the default sorting field and direction.
toSql()  : string
Returns the SQL expression used in the generic union
getDataByTag()  : array<string|int, mixed>
Returns a data stored about an item by its tag name.
getKeyNameByTag()  : string|null
Returns a model key name by its tag name.
getModelByTag()  : Model|mixed|null
Returns a prepared model by its tag name.
processCollection()  : Builder
Creates a generic union query of each added collection

Properties

$limitCount

public string $limitCount = null

Limits the number of results.

$limitOffset

public string $limitOffset = null

Set the limit offset.

$removeDuplicates

public bool $removeDuplicates = false

$sortDirection

public string $sortDirection = 'desc'

Default sorting direction.

$sortField

public string $sortField = 'id'

Default sorting attribute.

$sortVar

public string $sortVar = 'order_by_column_name'

An alias to use for each entries timestamp attribute.

$tagVar

public string $tagVar = 'tag_name'

The attribute to use for each model tag name.

$collection

protected array<string|int, mixed> $collection = []

Model collection pre-query.

$queryCache

protected Builder $queryCache

Cache containing the generic collection union query.

Methods

add()

Add a new Builder to the feed collection

public add(string $tag, Closure|Model|mixed $item[, string|null $orderBy = null ]) : DataFeed|void
Parameters
$tag : string
$item : Closure|Model|mixed
$orderBy : string|null = null
Return values
DataFeed|void

count()

Count the number of results from the generic union query

public count() : int
Return values
int

get()

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

public get() : Collection
Tags
throws
Exception

if the model is not found in the collection

Return values
Collection

limit()

Limits the number of results displayed.

public limit(int $count[, int|null $offset = null ]) : DataFeed
Parameters
$count : int
$offset : int|null = null
Return values
DataFeed

orderBy()

Sets the default sorting field and direction.

public orderBy(string $field[, string $direction = null ]) : DataFeed
Parameters
$field : string
$direction : string = null
Return values
DataFeed

toSql()

Returns the SQL expression used in the generic union

public toSql() : string
Return values
string

getDataByTag()

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

protected getDataByTag(string $tag) : array<string|int, mixed>
Parameters
$tag : string
Tags
throws
Exception

if the model is not found in the collection

Return values
array<string|int, mixed>

getKeyNameByTag()

Returns a model key name by its tag name.

protected getKeyNameByTag(string $tag) : string|null
Parameters
$tag : string
Tags
throws
Exception

if the model is not found in the collection

Return values
string|null

getModelByTag()

Returns a prepared model by its tag name.

protected getModelByTag(string $tag) : Model|mixed|null
Parameters
$tag : string
Tags
throws
Exception

if the model is not found in the collection

Return values
Model|mixed|null

processCollection()

Creates a generic union query of each added collection

protected processCollection() : Builder
Return values
Builder

Search results