Skip to content

Commit

Permalink
docs: updates CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeraymonddowning committed Sep 13, 2022
1 parent 7c2d80d commit ed55ea4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to `request-factories` will be documented in this file.

## 2.4.0 - 2022-09-13

- Added support for lazily resolving model factories [#24](https://github.com/worksome/request-factories/pull/24)
- Closures, nested request factories and model factories now work in infinitely nested arrays [#24](https://github.com/worksome/request-factories/pull/24)

## 2.3.0 - 2022-09-01

- Added a handy `RequestFactory::image` method as a shortcut for `$factory->file()->image('name.png')` [#23](https://github.com/worksome/request-factories/pull/23)
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,26 @@ Now, when the `SignupRequestFactory` is created, it will resolve the `AddressReq
and fill the `address` property with all fields contained in the `AddressRequestFactory` definition.
Pretty cool hey?

Request factories work hand in hand with model factories too. Imagine that you want to pass a `User` ID
to your form request, but you need to create the user in the database in order to do so. It's as simple
as instantiating the `UserFactory` in your request factory definition:

```php
class StoreMovieController extends RequestFactory
{
public function definition(): array
{
return [
'name' => 'My Cool Movie'
'owner_id' => User::factory(),
];
}
}
```

Because the `UserFactory` isn't created until compile time, we avoid any unexpected models being persisted to your test database
when you manually override the `owner_id` field.

### Using factories without form requests

Not every controller in your app requires a backing form request. Thankfully, we also support faking a generic request:
Expand Down

0 comments on commit ed55ea4

Please sign in to comment.