mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +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
@@ -156,6 +156,18 @@ After publishing vendor, simply change the `include_fluent` line your `config/id
|
||||
And then run `php artisan ide-helper:generate` , you will now see all of the Fluent methods are recognized by your IDE.
|
||||
|
||||
|
||||
### Auto-completion for factory builders
|
||||
|
||||
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.
|
||||
|
||||
```php
|
||||
'include_factory_builders' => true,
|
||||
```
|
||||
|
||||
For this to work, you must also publish the PhpStorm Meta file (see below).
|
||||
|
||||
|
||||
## PhpStorm Meta for Container instances
|
||||
|
||||
It's possible to generate a PhpStorm meta file to [add support for factory design pattern](https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata). For Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container. For example, `events` will return an `Illuminate\Events\Dispatcher` object, so with the meta file you can call `app('events')` and it will autocomplete the Dispatcher methods.
|
||||
|
||||
Reference in New Issue
Block a user