trait HasFiles (View source)

Methods

MorphToMany
files()

Defines the many-to-many relationship for file objects.

string|null
file(string $role, string|null $locale = null, File|null $file = null)

Returns the URL of the attached file for a role.

array
filesList(string $role, string|null $locale = null)

Returns an array of URLs of all attached files for a role.

File|null
fileObject(string $role, string|null $locale = null)

Returns the file object attached for a role.

Details

MorphToMany files()

Defines the many-to-many relationship for file objects.

Return Value

MorphToMany

string|null file(string $role, string|null $locale = null, File|null $file = null)

Returns the URL of the attached file for a role.

Parameters

string $role

Role name.

string|null $locale

Locale of the file if your site has multiple languages.

File|null $file

Provide a file object if you already retrieved one to prevent more SQL queries.

Return Value

string|null

array filesList(string $role, string|null $locale = null)

Returns an array of URLs of all attached files for a role.

Parameters

string $role

Role name.

string|null $locale

Locale of the file if your site has multiple languages.

Return Value

array

File|null fileObject(string $role, string|null $locale = null)

Returns the file object attached for a role.

Parameters

string $role

Role name.

string|null $locale

Locale of the file if your site has multiple languages.

Return Value

File|null