[LARAVEL 8] include_factory_builders does not work anymore (#1047) (#1049)

* [LARAVEL 8] include_factory_builders does not work anymore (#1047)

* Change skip expression
Append comment about deprecated to config file
Append comment about deprecated to README file
This commit is contained in:
Igor Finagin
2020-09-20 08:36:35 +02:00
committed by GitHub
parent 2ff9672a49
commit fd4d280a80
4 changed files with 35 additions and 7 deletions
+14 -7
View File
@@ -12,18 +12,25 @@ class Factories
{
$factories = [];
$factory = app(Factory::class);
if (static::isLaravelSevenOrLower()) {
$factory = app(Factory::class);
$definitions = (new ReflectionClass(Factory::class))->getProperty('definitions');
$definitions->setAccessible(true);
$definitions = (new ReflectionClass(Factory::class))->getProperty('definitions');
$definitions->setAccessible(true);
foreach ($definitions->getValue($factory) as $factory_target => $config) {
try {
$factories[] = new ReflectionClass($factory_target);
} catch (Exception $exception) {
foreach ($definitions->getValue($factory) as $factory_target => $config) {
try {
$factories[] = new ReflectionClass($factory_target);
} catch (Exception $exception) {
}
}
}
return $factories;
}
protected static function isLaravelSevenOrLower()
{
return class_exists('Illuminate\Database\Eloquent\Factory');
}
}