@@ -13,12 +13,20 @@ Create action has the following event hooks:
1313To use the event hook, just add the methods on your editor class.
1414
1515``` php
16- public function creating(Model $model, array $data) {
17- return $data;
16+ public function creating(Model $model, array $data)
17+ {
18+ // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required
19+ // to return the $model.
20+ // In version 1.8.0+ the hook must return the $model instance:
21+ return $model;
1822}
1923
20- public function created(Model $model, array $data) {
21- return $data;
24+ public function created(Model $model, array $data)
25+ {
26+ // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required
27+ // to return the $model.
28+ // In version 1.8.0+ the hook must return the $model instance:
29+ return $model;
2230}
2331```
2432
@@ -34,11 +42,34 @@ To use the event hook, just add the methods on your editor class.
3442
3543``` php
3644public function updating(Model $model, array $data) {
37- return $data;
45+ // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required
46+ // to return the $model.
47+ // In version 1.8.0+ the hook must return the $model:
48+ return $model;
3849}
3950
4051public function updated(Model $model, array $data) {
41- return $data;
52+ // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required
53+ // to return the $model.
54+ // In version 1.8.0+ the hook must return the $model instance:
55+ return $model;
56+ }
57+ ```
58+
59+ <a name =" saved-event " ></a >
60+ ## Saved event
61+
62+ In addition to create and edit events, the ` saved ` event hook is called after ` created ` and ` saved ` .
63+
64+ To use the event hook, just add the method on your editor class:
65+
66+ ``` php
67+ public function saved(Model $model, array $data)
68+ {
69+ // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required
70+ // to return the $model.
71+ // In version 1.8.0+ the hook must return the $model instance:
72+ return $model;
4273}
4374```
4475
@@ -47,17 +78,21 @@ public function updated(Model $model, array $data) {
4778
4879Remove action has the following event hooks:
4980
50- - ` deleting ` event hook that is fired before deleting a new record.
81+ - ` deleting ` event hook that is fired before deleting a record.
5182- ` deleted ` event hook that is fired after the record was deleted.
5283
5384To use the event hook, just add the methods on your editor class.
5485
5586``` php
5687public function deleting(Model $model, array $data) {
57- return $data;
88+ // Record still exists in database. Code can be used to delete records from
89+ // child tables that don't specify cascade deletes on the foreign key
90+ // definition.
5891}
5992
6093public function deleted(Model $model, array $data) {
61- return $data;
94+ // Record no longer exists in database, but $model instance still contains
95+ // data as it was before deleting. Any instance state mutation will be
96+ // preserved and returned in the 'data' array of the response.
6297}
6398```
0 commit comments