trait HasMedia

Properties

protected array $unAttachedMediaItems

Methods

static 
bootHasMedia()

No description

mixed
media()

Set the polymorphic relation.

void
scopeWhereHasMedia(Builder $query, string|string[] $tags)

Query scope to detect the presence of one or more attached media for a given tag.

newMediaInstance()

No description

getAttribute($key)

No description

setAttribute($key, $value)

No description

getDefaultTagName()

No description

string
getThumb(array $options = [], string $tag = null)

Get the thumbnail of the first media item of a default tag.

Collection
getMedia(string $tag = null, array|callable $filters = [])

Get a collection of media attachments by its tag.

Media|null
getFirstMedia(string $tag = null, array $filters = [])

Get the first media item of a media tag.

findMedia($mediaId)

No description

Collection
loadMedia($tag)

Lazy eager load attached media relationships.

bool
hasMedia(string $tag = null)

Determine if the specified tag contains media.

Collection
syncMedia(mixed $media, string $tag = null)

Replace the existing media collection for the specified tag(s).

void
deleteMedia(mixed $mediaId)

Detach a media item from the model.

deleteMediaExcept(mixed $media, string $tag = null)

Delete all media with the given tag except some.

void
clearMediaTag(string $tag = null)

Remove all media with the given tag.

prepareUnattachedMedia(Media $media, MediaAdder $mediaAdder)

No description

processUnattachedMedia(callable $callable)

No description

mediable()

No description

mediaWasLoaded()

No description

void
handleHasMediaDeletion()

Delete media relationships when the model is deleted. Ignore on soft deletes.

buildMediaPropertiesFilter(array $filters)

Convert the given array to a filter closure.

array
parseIds(mixed $value)

Get all of the IDs from the given mixed value.

Details

at line 20
static bootHasMedia()

No description

at line 32
mixed media()

Set the polymorphic relation.

Return Value

mixed

at line 43
void scopeWhereHasMedia(Builder $query, string|string[] $tags)

Query scope to detect the presence of one or more attached media for a given tag.

Parameters

Builder $query
string|string[] $tags

Return Value

void

at line 53
newMediaInstance()

No description

at line 61
getAttribute($key)

No description

Parameters

$key

at line 75
setAttribute($key, $value)

No description

Parameters

$key
$value

at line 84
getDefaultTagName()

No description

at line 100
string getThumb(array $options = [], string $tag = null)

Get the thumbnail of the first media item of a default tag.

Parameters

array $options
string $tag

Return Value

string

at line 113
Collection getMedia(string $tag = null, array|callable $filters = [])

Get a collection of media attachments by its tag.

Parameters

string $tag
array|callable $filters

Return Value

Collection

at line 131
Media|null getFirstMedia(string $tag = null, array $filters = [])

Get the first media item of a media tag.

Parameters

string $tag
array $filters

Return Value

Media|null

at line 136
findMedia($mediaId)

No description

Parameters

$mediaId

at line 154
Collection loadMedia($tag)

Lazy eager load attached media relationships.

Parameters

$tag

Return Value

Collection

at line 172
bool hasMedia(string $tag = null)

Determine if the specified tag contains media.

Parameters

string $tag

Return Value

bool

at line 185
Collection syncMedia(mixed $media, string $tag = null)

Replace the existing media collection for the specified tag(s).

Parameters

mixed $media
string $tag

Return Value

Collection

at line 211
void deleteMedia(mixed $mediaId)

Detach a media item from the model.

Parameters

mixed $mediaId

Return Value

void

at line 228
protected deleteMediaExcept(mixed $media, string $tag = null)

Delete all media with the given tag except some.

Parameters

mixed $media
string $tag

at line 244
void clearMediaTag(string $tag = null)

Remove all media with the given tag.

Parameters

string $tag

Return Value

void

at line 254
prepareUnattachedMedia(Media $media, MediaAdder $mediaAdder)

No description

Parameters

Media $media
MediaAdder $mediaAdder

at line 259
processUnattachedMedia(callable $callable)

No description

Parameters

callable $callable

at line 268
mediable()

No description

at line 284
protected mediaWasLoaded()

No description

at line 293
protected void handleHasMediaDeletion()

Delete media relationships when the model is deleted. Ignore on soft deletes.

Return Value

void

at line 307
protected Closure buildMediaPropertiesFilter(array $filters)

Convert the given array to a filter closure.

Parameters

array $filters

Return Value

Closure

at line 328
protected array parseIds(mixed $value)

Get all of the IDs from the given mixed value.

Parameters

mixed $value

Return Value

array