Skip to content

Commit

Permalink
SoftCascade fix
Browse files Browse the repository at this point in the history
  • Loading branch information
diego-betalabs committed Apr 20, 2017
1 parent 113a1d7 commit 14e72c8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"require-dev": {
"laravel/laravel": "5.*",
"phpunit/phpunit": "4.*",
"laravel/framework": "5.*",
"laravel/framework": "5.4",
"laravel/lumen-framework": "5.*",
"codacy/coverage": "dev-master"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Listeners/CascadeDeleteListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class CascadeDeleteListener
* Handel the event for eloquent delete.
*
* @param $event
* @param $model
* @param $models
* @return void
*/
public function handle($event, $model)
public function handle($event, $models)
{
(new SoftCascade())->cascade($model, 'delete');
(new SoftCascade())->cascade($models, 'delete');
}
}
6 changes: 3 additions & 3 deletions src/Listeners/CascadeRestoreListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class CascadeRestoreListener
* Handel the event for eloquent restore.
*
* @param $event
* @param $model
* @param $models
* @return void
*/
public function handle($event, $model)
public function handle($event, $models)
{
(new SoftCascade())->cascade($model, 'restore');
(new SoftCascade())->cascade($models, 'restore');
}
}
7 changes: 5 additions & 2 deletions src/SoftCascade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ class SoftCascade
*
* @return void
*/
public function cascade($model, $direction)
public function cascade($models, $direction)
{
$this->direction = $direction;

$this->run($model);
foreach($models as $model) {
$this->run($model);
}

}

/**
Expand Down

0 comments on commit 14e72c8

Please sign in to comment.