Skip to content

Commit 40cc8fb

Browse files
authored
add docs about fileName in uploadFileToDisk (#386)
1 parent f5b3c57 commit 40cc8fb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

5.x/crud-fields.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ public function setImageAttribute($value)
959959
$disk = "public";
960960
$destination_path = "folder_1/subfolder_1";
961961

962-
$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);
962+
$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path, $fileName = null);
963963

964964
// return $this->attributes[{$attribute_name}]; // uncomment if this is a translatable field
965965
}
@@ -969,7 +969,7 @@ public function setImageAttribute($value)
969969

970970
The field sends the file, through a Request, to the Controller. The Controller then tries to create/update the Model. That's when the mutator on your model will run. That also means we can do any [file validation](https://laravel.com/docs/5.3/validation#rule-file) (```file```, ```image```, ```mimetypes```, ```mimes```) in the Request, before the file is stored on the disk.
971971

972-
>NOTE: If this field is mandatory (required in validation) please use the [sometimes laravel validation rule](https://laravel.com/docs/5.8/validation#conditionally-adding-rules) together with **required** in your validation. (sometimes|required|file etc... )
972+
>NOTE: If this field is mandatory (required in validation) please use the [sometimes laravel validation rule](https://laravel.com/docs/9.x/validation#conditionally-adding-rules) together with **required** in your validation. (sometimes|required|file etc... )
973973
974974
[The ```uploadFileToDisk()``` method](https://github.com/Laravel-Backpack/CRUD/blob/master/src/app/Models/Traits/HasUploadFields.php#L31-L59) will take care of everything for most use cases:
975975

@@ -984,7 +984,7 @@ The field sends the file, through a Request, to the Controller. The Controller t
984984
* - if the value is null, deletes the file and sets null in the DB
985985
* - if the value is different, stores the different file and updates DB value
986986
* /
987-
public function uploadFileToDisk($value, $attribute_name, $disk, $destination_path) {}
987+
public function uploadFileToDisk($value, $attribute_name, $disk, $destination_path, $fileName = null) {}
988988
```
989989

990990
If you wish to have a different functionality, you can delete the method call from your mutator and do your own thing.

0 commit comments

Comments
 (0)