Skip to content

Commit 1e66ce7

Browse files
event documentation
1 parent 7f50047 commit 1e66ce7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,42 @@ PR is welcome!
4040

4141
![FileManager screenshot 2](http://unisharp.com/img/filemanager2.png)
4242

43+
## Events
44+
45+
To use events you can add a listener to listen to the events
46+
47+
Snippet for `EventServiceProvider`
48+
```php
49+
protected $listen = [
50+
ImageWasUploaded::class => [
51+
UploadListener::class,
52+
],
53+
];
54+
```
55+
56+
The `UploadListener` will look like:
57+
```php
58+
class UploadListener
59+
{
60+
public function handle($event)
61+
{
62+
$method = 'on'.class_basename($event);
63+
if (method_exists($this, $method)) {
64+
call_user_func([$this, $method], $event);
65+
}
66+
}
67+
68+
public function onImageWasUploaded(ImageWasUploaded $event)
69+
{
70+
$path = $event->path();
71+
//your code, for example resizing and cropping
72+
}
73+
}
74+
```
75+
76+
List of events:
77+
* Unisharp\Laravelfilemanager\Events\ImageWasUploaded
78+
4379
## Credits
4480
* All contibutors from GitHub. (issues / PR)
4581
* Special thanks to

0 commit comments

Comments
 (0)