Skip to content
This repository was archived by the owner on Aug 22, 2021. It is now read-only.

Commit 3579e41

Browse files
committed
Bugfix. overtrue#31
1 parent 1ff9eb8 commit 3579e41

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/StorageManager.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ public function upload(Request $request)
6161

6262
$filename = $this->getFilename($file, $config);
6363

64-
$modifiedFilename = event(new Uploading($file, $filename, $config), [], true);
65-
$filename = !is_null($modifiedFilename) ? $modifiedFilename : $filename;
64+
if ($this->eventSupport()) {
65+
$modifiedFilename = event(new Uploading($file, $filename, $config), [], true);
66+
$filename = !is_null($modifiedFilename) ? $modifiedFilename : $filename;
67+
}
6668

6769
$this->store($file, $filename);
6870

@@ -75,11 +77,21 @@ public function upload(Request $request)
7577
'size' => $file->getSize(),
7678
];
7779

78-
event(new Uploaded($file, $response));
80+
if ($this->eventSupport()) {
81+
event(new Uploaded($file, $response));
82+
}
7983

8084
return response()->json($response);
8185
}
8286

87+
/**
88+
* @return bool
89+
*/
90+
public function eventSupport()
91+
{
92+
return class_exists('Illuminate\Foundation\Events\Dispatchable');
93+
}
94+
8395
/**
8496
* List all files of dir.
8597
*

0 commit comments

Comments
 (0)