Coder Social home page Coder Social logo

laravel-attachments's People

Contributors

dzandrey avatar gabsource avatar giekus avatar gjorgic avatar jyhsu2000 avatar mxmtsk avatar pes8 avatar sgotre avatar vongola12324 avatar yayann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-attachments's Issues

Not getting anything from attachments()->get()

Hi, i´m trying to generate one download button to a uploaded file. The upload its ok, i see him in the attachments table, but if i try to get all the attachments from my model, its returns nothing.

I tried this:
$curriculo = Curriculo::find($id);
$file = $curriculo->attachments()->get();
dd($anexos);

And it gives me a empty collection.

And yes, i can see my $id and getting my "curriculo" model fine.

Any idea how i can fix that?

additional fields in attachment model

Hi,

I'm trying to add a custom additional field(s) into attachments table,
so first I create a migration to add those fields,

then in the dropzone form I add those input elements

then in my controller:
(I try to attach the UploadedFile directly to the model instead of uploading to dropzone controller first then bind uuid)

$attachment = $user->attach(
    $request->file($request->input('file_key', 'file')), // <== the UploadedFile instance
    array_merge(array_only($request->input(), [
        'title',
        'description',
        'category', //  <== here is the additional field
        'key',
    ]), [
        'metadata' => ['dz_session_key' => csrf_token()], // <== actually this also got ignored
    ]) . // <== the $options argument
);

but this got ignored because

https://github.com/bnbwebexpertise/laravel-attachments/blob/master/src/Attachment.php#L77

so I'm wondering is it necessary to filter out fields other than ['title', 'description', 'key', 'disk'] ?
or was I doing something wrong?
what is the easiest way to achieve what I'm trying to do?

Thanks!!

Error when to attach a file to User Model

Hi,

I get this error message when I tried to attach an image to a user,
Here my code :

$avatar = $admin->attach(public_path().'/BKF/DzErpTheme/img/default-avatar.png',[
            'disk' => 'media',
            'title' => 'avatar',
            'description' => 'default avatar',
            'key' => 'avatar'.$admin->id,
        ]);

and here the error :

FatalThrowableError in Uuid.php line 66: Call to undefined function Bnb\Uuid\bcadd()

Please check it.

Too many folders with dropzone.js

Hello. Just connected lib to my project with vue-dropzone on frontend.
I worry about too many random folders created with every uploaded file. As i read linux filesystem (ext4fs for example) become slow with too many folders (about 10000 and more). If project is quite large i think there will be even more folder amount. And i can't change this behavior (from documentation). What do you think about it?
I found some link for ext4:
https://ext4.wiki.kernel.org/index.php/Ext4_Howto#Sub_directory_scalability

Add support attachment group

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!

Laravel 8 support

Hello,

When I'm trying to run composer require bnbwebexpertise/laravel-attachments to install the package, I'm getting the following error:

Using version ^1.0 for bnbwebexpertise/laravel-attachments
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Deprecation Notice: Class ParsedownExtraTest located in D:/code/vendor/erusev/parsedown-extra\test\ParsedownExtraTest.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Illuminate\Contracts\Container\BindingResolutionException

  Target [Bnb\Laravel\Attachments\Contracts\AttachmentContract] is not instantiable while building [Bnb\Laravel\Attachments\Console\Commands\CleanupAttachments].

  at D:\code\vendor\laravel\framework\src\Illuminate\Container\Container.php:1038
    1034▕         } else {
    1035▕             $message = "Target [$concrete] is not instantiable.";
    1036▕         }
    1037▕
  ➜ 1038▕         throw new BindingResolutionException($message);
    1039▕     }
    1040▕
    1041▕     /**
    1042▕      * Throw an exception for an unresolvable primitive.

  1   D:\code\vendor\laravel\framework\src\Illuminate\Container\Container.php:839
      Illuminate\Container\Container::notInstantiable("Bnb\Laravel\Attachments\Contracts\AttachmentContract")

  2   D:\code\vendor\laravel\framework\src\Illuminate\Container\Container.php:279
      Illuminate\Container\Container::build("Bnb\Laravel\Attachments\Contracts\AttachmentContract")
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json to its original content.

5.6

Do you have any plans to support version 5.6?

Duplicated file on binding

Hi team!. I'm using Laravel 5.4, i installed laravel-attachments Version 0.0.16 as suggested in documentation.

I'm storing a file usign Laravel Storage::put() method, then getting the url with Storage::url() and then passing this path to the $model->attach($path, $options) method.

Basically my problem is that once i execute $model->attach($path, $options), a new file is created in the "attachments" folder.

For this project i'm using Amazon s3 Storage and we're not about upgrading Laravel so far.

I really hope you could tell me how could i fix this or tell me what i am doing wrong.

Thanks!

Ignore migrations

Hello,

I'm using Tenancy and I have a problem with your migrations.
When I do a "artisan migrate:fresh", I don't want your migrations to automatically be run (because I want them for each Tenant, not for the "central app").

Can you do something so we can :

  • publish migrations
  • prevent them from being run

Laravel Sanctum does it very well : https://laravel.com/docs/9.x/sanctum#migration-customization

Thanks !

Deleted attachments not deleting from s3 when filesystems.default = local

See attached unit test and conf file.

  1. Set filesystems.default = local

  2. Set 'attachments.behavior.cascade_delete = true

  3. Create an object

  4. Add attachments as in attached unit test

  5. Confirm records exist DATABASE.attachments (see attached)
    attachment_table

  6. Confirm they are saved to AWS s3

  7. Delete attachments

  8. Delete object

  9. Confirm records are deleted from DATABASE.attachments

  10. Confirm they are STILL saved to AWS s3

If I repeat the steps above but change filesystems.default = s3, files are deleted in BOTH DATABASE.attachments and aws.s3 (expected behavior)

OpportunityRepositoryTest.php.txt
attachments.php.txt
filesystems.php.txt

No created directory

Hi,
Thanks for the good package
For some reason there is no created folder when I upload images successfully, the uploaded files are saved on the attachment model but I cannot access the given filepath.

Thanks!

Best way to handle multiple file uploads?

I see there is a hidden field that we can update and attach the file in the controller on save, which is beautiful logic. just want to find out what the best approach for multiple uploads with dropzone would be

attach to a model with UUID as primary key

hello, i have a model with UUID as a Primary key not ( big int ), so when i try to attach him a file i got an error , incompatible type uuid with big int on column modelèid , how to deal with this ? thanks

HasAttachment trait return Attachment model instead of extended

I've got extended model FileAttachment to add some relations. But when i use HasAttachment trait, i've got collection of Attachment models instead of FileAttachment.
In AppServiceProvider all bindings correct.
May be it would be nice to have model class name in config/attachments.php that we could have own model class in HasAttachment trait?

support Carbon 2

- bnbwebexpertise/laravel-attachments 1.x-dev requires nesbot/carbon ~1.20 -> satisfiable by nesbot/carbon[1.20.0, 1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.24.1, 1.24.2, 1.25.0, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2].

Ability to specify the Attachment model's connection

Currently an issue when handling multiple database connections, to get the relationship working you need to specify connections on both models, even if one just takes the default connection by default.

Perhaps just a configurable option?

Change migration name

Is it possible to change the migration name
/migrations/2017_02_21_070324_alter_attachments_table_extend_filetype.php

It executes before then
/migrations/2017_02_21_070324_create_attachments_table.php

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.