DataFeed
Model Data Feed class.
class Winter\Storm\Database\DataFeed
Combine various models in to a single feed.
Properties
public
$limitCount
:
int
= null
Limits the number of results.
public
$limitOffset
:
int
= null
Set the limit offset.
public
$removeDuplicates
:
bool
= false
public
$sortDirection
:
string
= "desc"
Default sorting direction.
public
$sortField
:
string
= "id"
Default sorting attribute.
public
$sortVar
:
string
= "order_by_column_name"
An alias to use for each entries timestamp attribute.
public
$tagVar
:
string
= "tag_name"
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
Property | Type | Description |
---|---|---|
$tag | string |
string
|
$item | Closure | EloquentModel | mixed |
Closure | EloquentModel | mixed
|
$orderBy | string | null |
string | null
|
public count () : integer
Count the number of results from the generic union query
public get () : Collection
Executes the generic union query and eager loads the results in to the added models
public
limit (int $count, int | null $offset = null
)
: DataFeed
Limits the number of results displayed.
Property | Type | Description |
---|---|---|
$count | int |
int
|
$offset | int | null |
int | null
|
public
orderBy (string $field, string $direction = null
)
: DataFeed
Sets the default sorting field and direction.
Property | Type | Description |
---|---|---|
$field | string |
string
|
$direction | string |
string
|
public toSql () : string
Returns the SQL expression used in the generic union
protected getDataByTag (string $tag) : array
Returns a data stored about an item by its tag name.
Property | Type | Description |
---|---|---|
$tag | string |
string
|
protected getKeyNameByTag (string $tag) : string | null
Returns a model key name by its tag name.
Property | Type | Description |
---|---|---|
$tag | string |
string
|
protected getModelByTag (string $tag) : EloquentModel | mixed | null
Returns a prepared model by its tag name.
Property | Type | Description |
---|---|---|
$tag | string |
string
|
protected processCollection () : Builder
Creates a generic union query of each added collection