Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 35ccdc2

Browse files
committed
Adding doc on how to auto hydrate fields when updating a record. Based on #78, closes #77
1 parent 0933556 commit 35ccdc2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,12 @@ That's it! All we've done is remove the boring stuff.
235235

236236
Believe it or not, the code above performs essentially the same task as its older, albeit rather verbose sibling. Ardent populates the model object with attributes from user submitted form data (it uses the Laravel `Input::all()` method internally). No more hair-pulling trying to find out which Eloquent property you've forgotten to populate. Let Ardent take care of the boring stuff, while you get on with the fun stuffs!
237237

238-
To enable the auto-hydration feature, simply set the `$autoHydrateEntityFromInput` instance variable to `true` in your model class:
238+
To enable the auto-hydration feature, simply set the `$autoHydrateEntityFromInput` instance variable to `true` in your model class. However, to prevent filling pre-existent properties, if you want auto-hydration also for update scenarios, you should also use `$forceEntityHydrationFromInput`:
239239

240240
```php
241241
class User extends \LaravelBook\Ardent\Ardent {
242-
public $autoHydrateEntityFromInput = true;
242+
public $autoHydrateEntityFromInput = true; // hydrates on new entries
243+
public $forceEntityHydrationFromInput = true; // hydrates on updates
243244
}
244245
```
245246

0 commit comments

Comments
 (0)