Skip to content
Last updated

WHMCS\Download\Download

Class · extends AbstractModel

A downloadable file.

This object contains information about a specific file made available for download.

All Downloads belong to one or more Download\Categories. The number of times this file has been downloaded is tracked by timesDownloaded, a value incremented upon download.

The location on the filesystem for this specific download is stored here as well.

Each download file can be flagged as a Product Download (upon which a Client must have an instance of the related Product as a Service in order to download the file), as available only to Clients to be downloaded, or flagged as "hidden."

A hidden file is never provided in the client's user interface for download, in any category, hidden or otherwise.

Methods

public function asLink()

Represent a download as a file download link.

Returns string

downloadCategory

public function downloadCategory()

A download exists within a category.

Returns \Illuminate\Database\Eloquent\Relations\BelongsTo

products

public function products()

A download can be associated with one or more products.

Returns \Illuminate\Database\Eloquent\Relations\BelongsToMany

scopeConsiderProductDownloads

public function scopeConsiderProductDownloads(Builder $query)

scopeTopDownloads

public function scopeTopDownloads(Builder $query, $count = 5)

Look for "top" downloads.

Top downloads are the most downloaded downloads that are not hidden and belong to a non-hidden category.

Parameters

TypeNameDescription
Builder$query
int$count

Returns Builder

boot

public static function boot()

Bind events to download objects.

translatedNames

public function translatedNames()

Return the translated names for the specific download

Returns \Illuminate\Database\Eloquent\Relations\HasMany\|\WHMCS\Language\DynamicTranslation[]

translatedDescriptions

public function translatedDescriptions()

Return the translated names for the specific download

Returns \Illuminate\Database\Eloquent\Relations\HasMany\|\WHMCS\Language\DynamicTranslation[]

scopeInCategory

public function scopeInCategory(Builder $query, $catId)

scopeVisible

public function scopeVisible(Builder $query)

Scopes model to return visible downloads only

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeCategoryVisible

public function scopeCategoryVisible(Builder $query)

scopeSearch

public function scopeSearch(Builder $query, $search)