When you register an observer on the parent class that has self as childType it throws Error : Maximum function nesting level of '256' reached, aborting!.
Example
<?php
class User
{
use \Tightenco\Parental\HasChildren;
protected $childTypes = [
'super_admin' => Admin::class,
'admin' => self::class
];
}
// AppServiceProvider.php
class AppServiceProvider
{
public function boot(Environment $environment)
{
User::Observe(UserObserver::class);
}
}
Solution
This line should check if $childClass is not an instance of self.
foreach ((new self)->childTypes as $childClass) {
if ($childClass !== self::class) {
$childClass::registerModelEvent($event, $callback);
}
}
When you register an observer on the parent class that has
self
aschildType
it throwsError : Maximum function nesting level of '256' reached, aborting!
.Example
Solution
This line should check if
$childClass
is not an instance of self.