File tree 5 files changed +73
-8
lines changed
5 files changed +73
-8
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All Notable changes to ` laravel-uploadable ` will be documented in this file
4
4
5
+ ## 3.1.0 - 2019-04-24
6
+ ### ADD
7
+ - Events for upload and delete upload successfull.
8
+ - Back compatibility to laravel 5.0 in composer.json.
9
+
10
+
5
11
## 3.0.2 - 2018-10-28
6
12
### CHANGE
7
13
- readme.md
Original file line number Diff line number Diff line change 17
17
],
18
18
"require" : {
19
19
"php" : " >=7.0.0" ,
20
- "illuminate/http" : " ^5.7" ,
21
- "illuminate/database" : " ^5.7" ,
22
- "illuminate/support" : " ^5.7" ,
20
+ "illuminate/http" : " ^5.0|^5. 7" ,
21
+ "illuminate/database" : " ^5.0|^5. 7" ,
22
+ "illuminate/support" : " ^5.0|^5. 7" ,
23
23
"padosoft/io" : " ^1.0" ,
24
- "padosoft/laravel-request" : " ^2.0" ,
25
- "padosoft/support" : " ^2.1"
24
+ "padosoft/laravel-request" : " ^1.0|^ 2.0" ,
25
+ "padosoft/support" : " ^1.6|^ 2.1"
26
26
},
27
27
"require-dev" : {
28
- "orchestra/testbench" : " ^3.7" ,
29
- "phpunit/phpunit" : " ^7.0" ,
28
+ "orchestra/testbench" : " ^3.2|^3. 7" ,
29
+ "phpunit/phpunit" : " ^5.0|^ 7.0" ,
30
30
"mockery/mockery" : " ^0.9.5" ,
31
- "padosoft/test" : " ^1.0.1"
31
+ "padosoft/test" : " ^0.2.2|^ 1.0.1"
32
32
},
33
33
"autoload" : {
34
34
"psr-4" : {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ namespace Padosoft \Uploadable \Events ;
5
+
6
+ use Illuminate \Database \Eloquent \Model ;
7
+
8
+ class UploadDeleteExecuted
9
+ {
10
+ /**
11
+ * @var String
12
+ */
13
+ public $ attributeName ;
14
+ /**
15
+ * @var String
16
+ */
17
+ public $ attributeValue ;
18
+ /**
19
+ * @var Model
20
+ */
21
+ public $ target ;
22
+
23
+ public function __construct ($ attributeName , $ attributeValue , $ target )
24
+ {
25
+ $ this ->attributeName = $ attributeName ;
26
+ $ this ->attributeValue = $ attributeValue ;
27
+ $ this ->target = $ target ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ namespace Padosoft \Uploadable \Events ;
5
+
6
+ use Illuminate \Database \Eloquent \Model ;
7
+
8
+ class UploadExecuted
9
+ {
10
+ /**
11
+ * @var String
12
+ */
13
+ public $ attributeName ;
14
+ /**
15
+ * @var Model
16
+ */
17
+ public $ target ;
18
+
19
+ public function __construct ($ attributeName , $ target )
20
+ {
21
+ $ this ->attributeName = $ attributeName ;
22
+ $ this ->target = $ target ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change 11
11
use Padosoft \Io \FileHelper ;
12
12
use Padosoft \Laravel \Request \RequestHelper ;
13
13
use Padosoft \Laravel \Request \UploadedFileHelper ;
14
+ use Padosoft \Uploadable \Events \UploadDeleteExecuted ;
14
15
15
16
/**
16
17
* Class Uploadable
@@ -323,11 +324,16 @@ public function setBlanckAttributeAndDB(string $uploadField)
323
324
return ;
324
325
}
325
326
327
+ //old value
328
+ $ old = $ this ->{$ uploadField };
329
+
326
330
//set to black attribute
327
331
$ this ->{$ uploadField } = '' ;
328
332
329
333
//save on db (not call model save because invoke event and entering in loop)
330
334
$ this ->updateDb ($ uploadField , '' );
335
+
336
+ event (new UploadDeleteExecuted ($ uploadField , $ old , $ this ));
331
337
}
332
338
333
339
/**
You can’t perform that action at this time.
0 commit comments