Laravel-Backpack / demo

A working demo of Laravel with all Backpack packages installed.
http://backpackforlaravel.com
Other
329 stars 165 forks source link

Catch `withMedia` and `withFiles` to prevent uploads in Production #528

Open tabacitu opened 1 year ago

tabacitu commented 1 year ago

In https://github.com/Laravel-Backpack/demo/pull/456 we were talking about preventing the uploads in a more general way. Pedro came up with this solution and I like it:


We can catch the withMedia and withFiles, with that we prevent the uploader events from beeing registered, so we wouldn't even need to bind into the uploader classes as they wouldn't be registered/called.

That wouldn't prevent much, just the upload from happening, but anything you submit in the input would be saved to the database, except it didn't go through the upload process.

At the moment we can't bind to our uploaders as they aren't resolved from the container, they are statically initialized. We can work that out, or use the mutator as we are doing now. Everything is "working", except we always send empty values to the uploaders 🤷

Probably it's like you said, it's more future proof, but at the moment it's not a requirement.

_Originally posted by @pxpm in https://github.com/Laravel-Backpack/demo/pull/456#discussion_r1245294511_