bnbwebexpertise/laravel-attachments

Add support attachment group

Closed this issue · 3 comments

Hi @gabsource thanks for great package!

Just want to ask a question, will laravel-attachments support attachment group?

In my case, a user have a avatar, this can easily done with:

    // attach
    $user->attach(somefile, ['
        'key' => 'avatar',
    ']);

    // get
    $user->attachment('avatar');

But how about if user have a personal photo album? I try with:

    // with multiple uploads
    $user->attach(somefile, ['
        'key' => 'album',
    ']);

But when I want to get all photos with $user->attachment('gallery');, this only return 1 (last added) photo.

Maybe something like:

    // with multiple uploads
    $user->attach(somefile, ['
        'group' => 'album',
    ']);

    // get Collection
    $user->groupAttachments('album');

it would really help me out.

I can add additional column as #8 , but with group option and the method groupAttachments() will make it easier to use.

Thanks!

Hi,

Does the implementation in the attached branch fits your needs ?

Hi @gabsource , yes, the implementation exactly fit my needs. Thanks!

Available in v0.0.15. Requires to run migration to add the group column.