PHP Class Spatie\MediaLibrary\MediaRepository

Afficher le fichier Open project: spatie/laravel-medialibrary Class Usage Examples

Protected Properties

Свойство Type Description
$model Media

Méthodes publiques

Méthode Description
__construct ( Media $model )
all ( ) : Illuminate\Database\Eloquent\Collection Get all media.
getByCollectionName ( string $collectionName ) : Illuminate\Database\Eloquent\Collection * Get all media for the given type and collection name.
getByIds ( array $ids ) : Illuminate\Database\Eloquent\Collection * Get media by ids.
getByModelType ( string $modelType ) : Illuminate\Database\Eloquent\Collection * Get all media for the given type.
getByModelTypeAndCollectionName ( string $modelType, string $collectionName ) : Illuminate\Database\Eloquent\Collection * Get all media for the given type and collection name.
getCollection ( Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia $model, string $collectionName, array | callable $filter = [] ) : Collection Get all media in the collection.

Méthodes protégées

Méthode Description
applyFilterToMediaCollection ( Collection $media, array | callable $filter ) : Collection Apply given filters on media.
getDefaultFilterFunction ( array $filters ) : Closure Convert the given array to a filter function.
loadMedia ( Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia $model, string $collectionName ) : mixed Load media by collectionName.
mediaIsPreloaded ( Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia $model ) : boolean * Determine if media is already preloaded on this model.

Method Details

__construct() public méthode

public __construct ( Media $model )
$model Media

all() public méthode

Get all media.
public all ( ) : Illuminate\Database\Eloquent\Collection
Résultat Illuminate\Database\Eloquent\Collection

applyFilterToMediaCollection() protected méthode

Apply given filters on media.
protected applyFilterToMediaCollection ( Collection $media, array | callable $filter ) : Collection
$media Illuminate\Support\Collection
$filter array | callable
Résultat Illuminate\Support\Collection

getByCollectionName() public méthode

* Get all media for the given type and collection name.
public getByCollectionName ( string $collectionName ) : Illuminate\Database\Eloquent\Collection
$collectionName string
Résultat Illuminate\Database\Eloquent\Collection

getByIds() public méthode

* Get media by ids.
public getByIds ( array $ids ) : Illuminate\Database\Eloquent\Collection
$ids array
Résultat Illuminate\Database\Eloquent\Collection

getByModelType() public méthode

* Get all media for the given type.
public getByModelType ( string $modelType ) : Illuminate\Database\Eloquent\Collection
$modelType string
Résultat Illuminate\Database\Eloquent\Collection

getByModelTypeAndCollectionName() public méthode

* Get all media for the given type and collection name.
public getByModelTypeAndCollectionName ( string $modelType, string $collectionName ) : Illuminate\Database\Eloquent\Collection
$modelType string
$collectionName string
Résultat Illuminate\Database\Eloquent\Collection

getCollection() public méthode

Get all media in the collection.
public getCollection ( Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia $model, string $collectionName, array | callable $filter = [] ) : Collection
$model Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia
$collectionName string
$filter array | callable
Résultat Illuminate\Support\Collection

getDefaultFilterFunction() protected méthode

Convert the given array to a filter function.
protected getDefaultFilterFunction ( array $filters ) : Closure
$filters array
Résultat Closure

loadMedia() protected méthode

Load media by collectionName.
protected loadMedia ( Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia $model, string $collectionName ) : mixed
$model Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia
$collectionName string
Résultat mixed

mediaIsPreloaded() protected méthode

* Determine if media is already preloaded on this model.
protected mediaIsPreloaded ( Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia $model ) : boolean
$model Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia
Résultat boolean

Property Details

$model protected_oe property

protected Media,Spatie\MediaLibrary $model
Résultat Media