-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
Hi, Mohd Saqueib Ansari!
Thank you very much for developing this package.
I have a suggestion for revision.
In the example, you describe a use case
$ user->update ($request->all());
But I often have a need to pass $ request->book parameters to the update method where the information about the file to be downloaded is kept, for example $request->book->cover
$book->update ($request->book);
But the autoUpload method cannot automatically download this file, because it checks the existence of the file so
if (request () -> hasFile ($ requestFileName)) {
$ this-> uploadImage (
request () -> file ($ requestFileName),
$ field
);
}
I have a suggestion to replace this part of the code, so
if (! empty ($ this-> attributes [$ requestFileName]) and $ this-> attributes [$ requestFileName] instanceof UploadedFile) {
$ this-> uploadImage (
$ this-> attributes [$ requestFileName],
$ field
);
}
As a result, the function will look like this
protected function autoUpload()
{
foreach ($this->getDefinedUploadFields() as $key => $val) {
$field = is_int($key) ? $val : $key;
$options = Arr::wrap($val);
// check if global upload is allowed, then in override in option
$autoUploadAllowed = Arr::get($options, 'auto_upload', $this->canAutoUploadImages());
if (!$autoUploadAllowed) {
continue;
}
// get the input file name
$requestFileName = Arr::get($options, 'file_input', $field);
if (!empty($this->attributes[$requestFileName]) and $this->attributes[$requestFileName] instanceof UploadedFile) {
$this->uploadImage(
$this->attributes[$requestFileName],
$field
);
}
}
}
Do you understand my point?
Can you include this change in the release?
Metadata
Metadata
Assignees
Labels
No labels