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.

class Download extends AbstractModel

Properties summary

Type Property Description
protected $table
protected $columnMap
protected $booleans
int $id Unique ID number for this download.
int $downloadCategoryId ID number of category this download belongs to.
string $type English internal name used to identify the download's type. One of this set: 'pdf', 'exe', 'zip'.
string $title Name the download will be listed as on the client side.
string $description Description displayed to the client for this file.
int $timesDownloaded This value should be incremented every time the file is downloaded. It is used to identify "Most Popular" downloads.
string $fileLocation Name of the file on the filesystem with it's root in /downloads/
bool $clientDownloadOnly If true, this download should only be available to clients.
bool $isHidden If true, this download should not be displayed to clients, only to admins.
bool $isProductDownload If true, this download is associated with a specific product.
Carbon $createdAt The date when this specific download was created.
Carbon $updatedAt The date this download was last updated.
Category $downloadCategory Category object to which this download belongs.
Collection|Product[] $products Array of all products this download is associated with.
Collection|DynamicTranslation[] $translatedNames
Collection|DynamicTranslation[] $translatedDescriptions

Methods summary

Return Type Method Name Description
string asLink() Represent a download as a file download link.
BelongsTo downloadCategory() A download exists within a category.
BelongsToMany products() A download can be associated with one or more products.
scopeConsiderProductDownloads(Builder $query) -
Builder scopeTopDownloads(Builder $query, int $count = 5) Look for "top" downloads.
static  boot() Bind events to download objects.
HasMany|DynamicTranslation[] translatedNames() Return the translated names for the specific download
HasMany|DynamicTranslation[] translatedDescriptions() Return the translated names for the specific download
scopeInCategory(Builder $query, $catId) -
Builder scopeVisible(Builder $query) Scopes model to return visible downloads only
scopeCategoryVisible(Builder $query) -
scopeSearch(Builder $query, $search) -

Details

Represent a download as a file download link.

Return Value

string

BelongsTo downloadCategory ()

A download exists within a category.

Return Value

BelongsTo

BelongsToMany products ()

A download can be associated with one or more products.

Return Value

BelongsToMany

scopeConsiderProductDownloads (Builder $query)

Parameters

Builder $query

Builder scopeTopDownloads (Builder $query, int $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

Builder $query
int $count

Return Value

Builder

static boot ()

Bind events to download objects.

HasMany|DynamicTranslation[] translatedNames ()

Return the translated names for the specific download

Return Value

HasMany|DynamicTranslation[]

HasMany|DynamicTranslation[] translatedDescriptions ()

Return the translated names for the specific download

Return Value

HasMany|DynamicTranslation[]

scopeInCategory (Builder $query, $catId)

Parameters

Builder $query
$catId

Builder scopeVisible (Builder $query)

Scopes model to return visible downloads only

Parameters

Builder $query

Return Value

Builder

scopeCategoryVisible (Builder $query)

Parameters

Builder $query

scopeSearch (Builder $query, $search)

Parameters

Builder $query
$search