PHP Трейт Spatie\MediaLibrary\HasMedia\HasMediaTrait

Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$mediaConversions array

Защищенные свойства (Protected)

Свойство Тип Описание
$deletePreservingMedia boolean

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

Метод Описание
addMedia ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file ) : FileAdder Add a file to the medialibrary.
addMediaConversion ( string $name ) : Conversion * Add a conversion.
addMediaFromRequest ( string $key ) : FileAdder Add a file from a request.
addMediaFromUrl ( string $url ) : FileAdder Add a remote file to the medialibrary.
bootHasMediaTrait ( )
clearMediaCollection ( string $collectionName = 'default' ) Remove all media in the given collection.
copyMedia ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file ) : FileAdder Copy a file to the medialibrary.
deleteMedia ( integer | Media $mediaId ) Delete the associated media with the given id.
deletePreservingMedia ( ) : boolean Delete the model, but preserve all the associated media.
getFirstMedia ( string $collectionName = 'default', array $filters = [] ) : Media | null Get the first media item of a media collection.
getFirstMediaPath ( string $collectionName = 'default', string $conversionName = '' ) : string * Get the url of the image for the given conversionName for first media for the given collectionName.
getFirstMediaUrl ( string $collectionName = 'default', string $conversionName = '' ) : string * Get the url of the image for the given conversionName for first media for the given collectionName.
getMedia ( string $collectionName = '', $filters = [] ) : Collection * Get media collection by its collectionName.
hasMedia ( string $collectionName = '' ) : boolean * Determine if there is media in the given collection.
media ( ) : mixed Set the polymorphic relation.
shouldDeletePreservingMedia ( ) : Media Determines if the media files should be preserved when the media object gets deleted.
updateMedia ( array $newMediaArray, string $collectionName = 'default' ) : array Update a media collection by deleting and inserting again with new values.

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

Метод Описание
removeMediaItemsNotPresentInArray ( array $newMediaArray, string $collectionName = 'default' )

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

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

Add a file to the medialibrary.
public addMedia ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file ) : FileAdder
$file string | Symfony\Component\HttpFoundation\File\UploadedFile
Результат Spatie\MediaLibrary\FileAdder\FileAdder

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

* Add a conversion.
public addMediaConversion ( string $name ) : Conversion
$name string
Результат Spatie\MediaLibrary\Conversion\Conversion

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

Add a file from a request.
public addMediaFromRequest ( string $key ) : FileAdder
$key string
Результат Spatie\MediaLibrary\FileAdder\FileAdder

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

Add a remote file to the medialibrary.
public addMediaFromUrl ( string $url ) : FileAdder
$url string
Результат Spatie\MediaLibrary\FileAdder\FileAdder

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

public static bootHasMediaTrait ( )

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

Remove all media in the given collection.
public clearMediaCollection ( string $collectionName = 'default' )
$collectionName string

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

Copy a file to the medialibrary.
public copyMedia ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file ) : FileAdder
$file string | Symfony\Component\HttpFoundation\File\UploadedFile
Результат Spatie\MediaLibrary\FileAdder\FileAdder

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

You may also pass a media object.
public deleteMedia ( integer | Media $mediaId )
$mediaId integer | Spatie\MediaLibrary\Media

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

Delete the model, but preserve all the associated media.
public deletePreservingMedia ( ) : boolean
Результат boolean

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

Get the first media item of a media collection.
public getFirstMedia ( string $collectionName = 'default', array $filters = [] ) : Media | null
$collectionName string
$filters array
Результат Spatie\MediaLibrary\Media | null

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

If no profile is given, return the source's url.
public getFirstMediaPath ( string $collectionName = 'default', string $conversionName = '' ) : string
$collectionName string
$conversionName string
Результат string

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

If no profile is given, return the source's url.
public getFirstMediaUrl ( string $collectionName = 'default', string $conversionName = '' ) : string
$collectionName string
$conversionName string
Результат string

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

* Get media collection by its collectionName.
public getMedia ( string $collectionName = '', $filters = [] ) : Collection
$collectionName string
$filters
Результат Illuminate\Support\Collection

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

* Determine if there is media in the given collection.
public hasMedia ( string $collectionName = '' ) : boolean
$collectionName string
Результат boolean

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

Set the polymorphic relation.
public media ( ) : mixed
Результат mixed

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

protected removeMediaItemsNotPresentInArray ( array $newMediaArray, string $collectionName = 'default' )
$newMediaArray array
$collectionName string

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

Determines if the media files should be preserved when the media object gets deleted.
public shouldDeletePreservingMedia ( ) : Media
Результат Spatie\MediaLibrary\Media

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

Update a media collection by deleting and inserting again with new values.
public updateMedia ( array $newMediaArray, string $collectionName = 'default' ) : array
$newMediaArray array
$collectionName string
Результат array

Описание свойств

$deletePreservingMedia защищенное свойство

protected bool $deletePreservingMedia
Результат boolean

$mediaConversions публичное свойство

public array $mediaConversions
Результат array