spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.78k stars 1.08k forks source link

Make hasMedia method signature compatible with getMedia in InteractsWithMedia #3712

Closed sten closed 1 month ago

sten commented 1 month ago

The $filters arg of hasMedia does not allow the callable type, while it just calls getMedia which does allow it.

public function hasMedia(string $collectionName = 'default', array $filters = []): bool
    {
        return count($this->getMedia($collectionName, $filters)) ? true : false;
    }

    /**
     * Get media collection by its collectionName.
     */
    public function getMedia(string $collectionName = 'default', array|callable $filters = []): MediaCollections\Models\Collections\MediaCollection
    { 
//omitted 
    }
timvandijck commented 1 month ago

Good spot. Thank you!