mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-17 17:47:13 +00:00
* [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:
@@ -256,6 +256,7 @@ Then run `php artisan ide-helper:generate`, you will now see all Fluent methods
|
|||||||
|
|
||||||
If you would like the `factory()->create()` and `factory()->make()` methods to return the correct model class,
|
If you would like the `factory()->create()` and `factory()->make()` methods to return the correct model class,
|
||||||
you can enable custom factory builders with the `include_factory_builders` line your `config/ide-helper.php` file.
|
you can enable custom factory builders with the `include_factory_builders` line your `config/ide-helper.php` file.
|
||||||
|
Deprecated for Laravel 8 or latest.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
'include_factory_builders' => true,
|
'include_factory_builders' => true,
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ return [
|
|||||||
| Set to true to generate factory generators for better factory()
|
| Set to true to generate factory generators for better factory()
|
||||||
| method auto-completion.
|
| method auto-completion.
|
||||||
|
|
|
|
||||||
|
| Deprecated for Laravel 8 or latest.
|
||||||
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'include_factory_builders' => false,
|
'include_factory_builders' => false,
|
||||||
|
|||||||
+14
-7
@@ -12,18 +12,25 @@ class Factories
|
|||||||
{
|
{
|
||||||
$factories = [];
|
$factories = [];
|
||||||
|
|
||||||
$factory = app(Factory::class);
|
if (static::isLaravelSevenOrLower()) {
|
||||||
|
$factory = app(Factory::class);
|
||||||
|
|
||||||
$definitions = (new ReflectionClass(Factory::class))->getProperty('definitions');
|
$definitions = (new ReflectionClass(Factory::class))->getProperty('definitions');
|
||||||
$definitions->setAccessible(true);
|
$definitions->setAccessible(true);
|
||||||
|
|
||||||
foreach ($definitions->getValue($factory) as $factory_target => $config) {
|
foreach ($definitions->getValue($factory) as $factory_target => $config) {
|
||||||
try {
|
try {
|
||||||
$factories[] = new ReflectionClass($factory_target);
|
$factories[] = new ReflectionClass($factory_target);
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $factories;
|
return $factories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function isLaravelSevenOrLower()
|
||||||
|
{
|
||||||
|
return class_exists('Illuminate\Database\Eloquent\Factory');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Factories;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Factories;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class AllTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testAll(): void
|
||||||
|
{
|
||||||
|
$factories = Factories::all();
|
||||||
|
|
||||||
|
self::assertEmpty($factories);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user