plank / laravel-mediable

Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel
MIT License
756 stars 100 forks source link

How to build filament component as plank does not exposes any interface like HasMedia #326

Closed khanakia closed 1 year ago

khanakia commented 1 year ago

Hi,

I am trying to build a Filament Component using Plank but i am unable to do so as plank mediable does not expose any HasMedia kind of interface like spatie does https://github.com/spatie/laravel-medialibrary/blob/main/src/HasMedia.php

In order to make my component i need an interface as shown on this line https://github.com/filamentphp/spatie-laravel-media-library-plugin/blob/3.x/src/Forms/Components/SpatieMediaLibraryFileUpload.php#L46

Any help would be appreciated thanks

khanakia commented 1 year ago

I am not getting why Plank does not expose any interface HasMedia now it's so hard to type hint the code e.g.

function (SpatieMediaLibraryFileUpload $component, HasMedia $record)

frasmage commented 1 year ago

Hello @khanakia,

This library does not follow the same method signatures as Spatie's media library, so we cannot adhere to the same interface, if that is what you are implying. The library that you linked looks like an adaptor, so you might want to create your own which adapts Mediable instead.

There definitely could be an interface for the methods exposed by the Mediable trait. This is the first time this has been requested. Pull requests always welcome! That said, there is also nothing stopping you from implementing such an interface in your own userland code and applying it to the same models that you are applying the Mediable trait.

khanakia commented 1 year ago

thanks, i will check