PHP Trait Spatie\MediaLibrary\HasMedia\HasMediaTrait

Afficher le fichier Open project: spatie/laravel-medialibrary

Méthodes publiques

Свойство Type Description
$mediaConversions array

Protected Properties

Свойство Type Description
$deletePreservingMedia boolean

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
removeMediaItemsNotPresentInArray ( array $newMediaArray, string $collectionName = 'default' )

Method Details

addMedia() public méthode

Add a file to the medialibrary.
public addMedia ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file ) : FileAdder
$file string | Symfony\Component\HttpFoundation\File\UploadedFile
Résultat Spatie\MediaLibrary\FileAdder\FileAdder

addMediaConversion() public méthode

* Add a conversion.
public addMediaConversion ( string $name ) : Conversion
$name string
Résultat Spatie\MediaLibrary\Conversion\Conversion

addMediaFromRequest() public méthode

Add a file from a request.
public addMediaFromRequest ( string $key ) : FileAdder
$key string
Résultat Spatie\MediaLibrary\FileAdder\FileAdder

addMediaFromUrl() public méthode

Add a remote file to the medialibrary.
public addMediaFromUrl ( string $url ) : FileAdder
$url string
Résultat Spatie\MediaLibrary\FileAdder\FileAdder

bootHasMediaTrait() public static méthode

public static bootHasMediaTrait ( )

clearMediaCollection() public méthode

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

copyMedia() public méthode

Copy a file to the medialibrary.
public copyMedia ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file ) : FileAdder
$file string | Symfony\Component\HttpFoundation\File\UploadedFile
Résultat Spatie\MediaLibrary\FileAdder\FileAdder

deleteMedia() public méthode

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

deletePreservingMedia() public méthode

Delete the model, but preserve all the associated media.
public deletePreservingMedia ( ) : boolean
Résultat boolean

getFirstMedia() public méthode

Get the first media item of a media collection.
public getFirstMedia ( string $collectionName = 'default', array $filters = [] ) : Media | null
$collectionName string
$filters array
Résultat Spatie\MediaLibrary\Media | null

getFirstMediaPath() public méthode

If no profile is given, return the source's url.
public getFirstMediaPath ( string $collectionName = 'default', string $conversionName = '' ) : string
$collectionName string
$conversionName string
Résultat string

getFirstMediaUrl() public méthode

If no profile is given, return the source's url.
public getFirstMediaUrl ( string $collectionName = 'default', string $conversionName = '' ) : string
$collectionName string
$conversionName string
Résultat string

getMedia() public méthode

* Get media collection by its collectionName.
public getMedia ( string $collectionName = '', $filters = [] ) : Collection
$collectionName string
$filters
Résultat Illuminate\Support\Collection

hasMedia() public méthode

* Determine if there is media in the given collection.
public hasMedia ( string $collectionName = '' ) : boolean
$collectionName string
Résultat boolean

media() public méthode

Set the polymorphic relation.
public media ( ) : mixed
Résultat mixed

removeMediaItemsNotPresentInArray() protected méthode

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

shouldDeletePreservingMedia() public méthode

Determines if the media files should be preserved when the media object gets deleted.
public shouldDeletePreservingMedia ( ) : Media
Résultat Spatie\MediaLibrary\Media

updateMedia() public méthode

Update a media collection by deleting and inserting again with new values.
public updateMedia ( array $newMediaArray, string $collectionName = 'default' ) : array
$newMediaArray array
$collectionName string
Résultat array

Property Details

$deletePreservingMedia protected_oe property

protected bool $deletePreservingMedia
Résultat boolean

$mediaConversions public_oe property

public array $mediaConversions
Résultat array