PHP Трейт Plank\Mediable\Mediable

Provides functionality for attaching media to an eloquent model.
Автор: Sean Fraser ([email protected])
Показать файл Открыть проект

Открытые методы

Метод Описание
attachMedia ( mixed $media, string | array $tags ) : void Attach a media entity to the model with one or more tags.
bootMediable ( ) : void Boot the Mediable trait.
detachMedia ( mixed $media, string | array | null $tags = null ) : void Detach a media item from the model.
detachMediaTags ( string | array $tags ) : void Remove one or more tags from the model, detaching any media using those tags.
firstMedia ( string | array $tags, boolean $match_all = false ) : boolean Shorthand for retrieving a single attached media.
getAllMediaByTag ( ) : Collection Retrieve all media grouped by tag name.
getMedia ( string | array $tags, boolean $match_all = false ) : boolean Retrieve media attached to the model.
getMediaMatchAll ( array $tags ) : boolean Retrieve media attached to multiple tags simultaneously.
getTagsForMedia ( Media $media ) : array Get a list of all tags that the media is attached to.
hasMedia ( string | array $tags, boolean $match_all = false ) : boolean Check if the model has any media attached to one or more tags.
load ( $relations )
loadMedia ( string | array $tags = [], boolean $match_all = false ) Lazy eager load attached media relationships.
loadMediaMatchAll ( string | array $tags = [] ) Lazy eager load attached media relationships matching all provided tags.
media ( ) : Illuminate\Database\Eloquent\Relations\MorphToMany Relationship for all attached media.
newCollection ( array $models = [] ) : Plank\Mediable\MediableCollection
scopeWhereHasMedia ( Builder $q, string | array $tags, boolean $match_all = false ) : void Query scope to detect the presence of one or more attached media for a given tag.
scopeWhereHasMediaMatchAll ( Builder $q, array $tags ) : void Query scope to detect the presence of one or more attached media that is bound to all of the specified tags simultaneously.
scopeWithMedia ( Builder $q, string | array $tags = [], boolean $match_all = false ) : void Query scope to eager load attached media.
scopeWithMediaMatchAll ( Builder $q, string | array $tags = [] ) : void Query scope to eager load attached media assigned to multiple tags.
syncMedia ( mixed $media, string | array $tags ) : void Replace the existing media collection for the specified tag(s).

Защищенные методы

Метод Описание
addMatchAllToEagerLoadQuery ( Illuminate\Database\Eloquent\Relations\MorphToMany $q, array | string $tags = [] ) : void Modify an eager load query to only load media assigned to all provided tags simultaneously.
handleMediableDeletion ( ) : void Determine whether media relationships should be detached when the model is deleted or soft deleted.
markMediaDirty ( string | array $tags ) : void Indicate that the media attached to the provided tags has been modified.
mediaIsDirty ( null | string | array $tags = null ) : boolean Check if media attached to the specified tags has been modified.
newMatchAllQuery ( array | string $tags = [] ) : [type] Generate a query builder for.
rehydrateMediaIfNecessary ( null | string | array $tags = null ) : void Reloads media relationship if allowed and necessary.
rehydratesMedia ( ) : boolean Check whether the model is allowed to automatically reload media relationship.

Приватные методы

Метод Описание
extractIds ( mixed $input ) : array Convert mixed input to array of ids.
getOrderValueForTags ( string | array $tags ) : integer Determine the highest order value assigned to each provided tag.

Описание методов

addMatchAllToEagerLoadQuery() защищенный Метод

Modify an eager load query to only load media assigned to all provided tags simultaneously.
protected addMatchAllToEagerLoadQuery ( Illuminate\Database\Eloquent\Relations\MorphToMany $q, array | string $tags = [] ) : void
$q Illuminate\Database\Eloquent\Relations\MorphToMany
$tags array | string
Результат void

attachMedia() публичный Метод

Attach a media entity to the model with one or more tags.
public attachMedia ( mixed $media, string | array $tags ) : void
$media mixed Either a string or numeric id, an array of ids, an instance of `Media` or an instance of `\Illuminate\Database\Eloquent\Collection`
$tags string | array One or more tags to define the relation
Результат void

bootMediable() публичный статический Метод

Boot the Mediable trait.
public static bootMediable ( ) : void
Результат void

detachMedia() публичный Метод

Detach a media item from the model.
public detachMedia ( mixed $media, string | array | null $tags = null ) : void
$media mixed
$tags string | array | null If provided, will remove the media from the model for the provided tag(s) only If omitted, will remove the media from the media for all tags
Результат void

detachMediaTags() публичный Метод

Remove one or more tags from the model, detaching any media using those tags.
public detachMediaTags ( string | array $tags ) : void
$tags string | array
Результат void

firstMedia() публичный Метод

Shorthand for retrieving a single attached media.
См. также: Plank\Mediable\Mediable::getMedia()
public firstMedia ( string | array $tags, boolean $match_all = false ) : boolean
$tags string | array
$match_all boolean
Результат boolean

getAllMediaByTag() публичный Метод

Retrieve all media grouped by tag name.
public getAllMediaByTag ( ) : Collection
Результат Illuminate\Support\Collection

getMedia() публичный Метод

Retrieve media attached to the model.
public getMedia ( string | array $tags, boolean $match_all = false ) : boolean
$tags string | array
$match_all boolean If false, will return media attached to any of the provided tags If true, will return media attached to all of the provided tags simultaneously
Результат boolean

getMediaMatchAll() публичный Метод

Retrieve media attached to multiple tags simultaneously.
public getMediaMatchAll ( array $tags ) : boolean
$tags array
Результат boolean

getTagsForMedia() публичный Метод

Get a list of all tags that the media is attached to.
public getTagsForMedia ( Media $media ) : array
$media Media
Результат array

handleMediableDeletion() защищенный Метод

Determine whether media relationships should be detached when the model is deleted or soft deleted.
protected handleMediableDeletion ( ) : void
Результат void

hasMedia() публичный Метод

Check if the model has any media attached to one or more tags.
public hasMedia ( string | array $tags, boolean $match_all = false ) : boolean
$tags string | array
$match_all boolean If false, will return true if the model has any attach media for any of the provided tags If true, will return true is the model has any media that are attached to all of provided tags simultaneously
Результат boolean

load() публичный Метод

public load ( $relations )

loadMedia() публичный Метод

Lazy eager load attached media relationships.
public loadMedia ( string | array $tags = [], boolean $match_all = false )
$tags string | array If one or more tags are specified, only media attached to those tags will be loaded.
$match_all boolean Only load media matching all provided tags

loadMediaMatchAll() публичный Метод

Lazy eager load attached media relationships matching all provided tags.
public loadMediaMatchAll ( string | array $tags = [] )
$tags string | array one or more tags

markMediaDirty() защищенный Метод

Indicate that the media attached to the provided tags has been modified.
protected markMediaDirty ( string | array $tags ) : void
$tags string | array
Результат void

media() публичный Метод

Relationship for all attached media.
public media ( ) : Illuminate\Database\Eloquent\Relations\MorphToMany
Результат Illuminate\Database\Eloquent\Relations\MorphToMany

mediaIsDirty() защищенный Метод

Check if media attached to the specified tags has been modified.
protected mediaIsDirty ( null | string | array $tags = null ) : boolean
$tags null | string | array If omitted, will return `true` if any tags have been modified
Результат boolean

newCollection() публичный Метод

public newCollection ( array $models = [] ) : Plank\Mediable\MediableCollection
$models array
Результат Plank\Mediable\MediableCollection

newMatchAllQuery() защищенный Метод

Generate a query builder for.
protected newMatchAllQuery ( array | string $tags = [] ) : [type]
$tags array | string [description]
Результат [type]

rehydrateMediaIfNecessary() защищенный Метод

Reloads media relationship if allowed and necessary.
protected rehydrateMediaIfNecessary ( null | string | array $tags = null ) : void
$tags null | string | array
Результат void

rehydratesMedia() защищенный Метод

Can be overridden by setting protected property $rehydrates_media on the model.
protected rehydratesMedia ( ) : boolean
Результат boolean

scopeWhereHasMedia() публичный Метод

Query scope to detect the presence of one or more attached media for a given tag.
public scopeWhereHasMedia ( Builder $q, string | array $tags, boolean $match_all = false ) : void
$q Illuminate\Database\Eloquent\Builder
$tags string | array
$match_all boolean
Результат void

scopeWhereHasMediaMatchAll() публичный Метод

Query scope to detect the presence of one or more attached media that is bound to all of the specified tags simultaneously.
public scopeWhereHasMediaMatchAll ( Builder $q, array $tags ) : void
$q Illuminate\Database\Eloquent\Builder
$tags array
Результат void

scopeWithMedia() публичный Метод

Query scope to eager load attached media.
public scopeWithMedia ( Builder $q, string | array $tags = [], boolean $match_all = false ) : void
$q Illuminate\Database\Eloquent\Builder
$tags string | array If one or more tags are specified, only media attached to those tags will be loaded.
$match_all boolean Only load media matching all provided tags
Результат void

scopeWithMediaMatchAll() публичный Метод

Query scope to eager load attached media assigned to multiple tags.
public scopeWithMediaMatchAll ( Builder $q, string | array $tags = [] ) : void
$q Illuminate\Database\Eloquent\Builder
$tags string | array
Результат void

syncMedia() публичный Метод

Replace the existing media collection for the specified tag(s).
public syncMedia ( mixed $media, string | array $tags ) : void
$media mixed
$tags string | array
Результат void