diff --git a/README.md b/README.md index e87a157..7cceee4 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,8 @@ To be able create the migrations, you need to add the following code to your con 8. `updateRule()`: updating a rule 9. `removeRule()`: removing a rule 10. `addChild()`: creating a child -11. `assign()`: assign a role to a user +12. `removeChild()`: removing a child +13. `assign()`: assign a role to a user ###Creating Migrations diff --git a/migrations/Migration.php b/migrations/Migration.php index 2ead707..55cbfd3 100644 --- a/migrations/Migration.php +++ b/migrations/Migration.php @@ -257,6 +257,26 @@ protected function addChild($parent, $child) echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; } + /** + * Removes child. + * + * @param Item|string $parent Either name or Item instance which is parent + * @param Item|string $child Either name or Item instance which is child + */ + protected function removeChild($parent, $child) + { + if (is_string($parent)) { + $parent = $this->findItem($parent); + } + if (is_string($child)) { + $child = $this->findItem($child); + } + echo " > removing $child->name from $parent->name ..."; + $time = microtime(true); + $this->authManager->removeChild($parent, $child); + echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; + } + /** * Assigns a role to a user. *