@@ -270,9 +270,6 @@ return [
'file' => 'files',
],
- // Overwriting an existing file.
- 'override' => env('ADMIN_UPLOAD_OVERRIDE', false),
-
/*
@@ -227,4 +227,11 @@ class File extends Field implements UploadFieldInterface
Helper::deleteContains($fieldRules, ['image', 'file', 'dimensions', 'size', 'max', 'min']);
}
+
+ public function override ( bool $override = true )
+ {
+ $this->options['override'] = $override;
+ return $this;
+ }
@@ -98,7 +98,7 @@ trait UploadField
*/
public function renameIfExists(UploadedFile $file)
{
- if ($this->getStorage()->exists("{$this->getDirectory()}/$this->name") && ! config('admin.upload.override')) {
+ if ($this->getStorage()->exists("{$this->getDirectory()}/$this->name") && ! ($this->options['override'] ?? false)) {
$this->name = $this->generateUniqueName($file);