mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Add support for factory()->create() return types (#758)
* Revert "Forked release" * Initial factory builder support * Oops — fixed tabs * Revert "Forked release" * Whitespace * Reverted more code * Whitespace * More whitespace * Fixed PHPCS line
This commit is contained in:
committed by
Barry vd. Heuvel
parent
25b61c56fe
commit
6c8e847430
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
use ReflectionClass;
|
||||
|
||||
class Factories
|
||||
{
|
||||
|
||||
public static function all()
|
||||
{
|
||||
$factories = [];
|
||||
|
||||
$factory = app(Factory::class);
|
||||
|
||||
$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) {
|
||||
}
|
||||
}
|
||||
|
||||
return $factories;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user