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

Commit

Permalink
Adding doc on how to auto hydrate fields when updating a record. Base…
Browse files Browse the repository at this point in the history
…d on #78, closes #77
  • Loading branch information
igorsantos07 committed Aug 2, 2013
1 parent 0933556 commit 35ccdc2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ That's it! All we've done is remove the boring stuff.

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!

To enable the auto-hydration feature, simply set the `$autoHydrateEntityFromInput` instance variable to `true` in your model class:
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`:

```php
class User extends \LaravelBook\Ardent\Ardent {
public $autoHydrateEntityFromInput = true;
public $autoHydrateEntityFromInput = true; // hydrates on new entries
public $forceEntityHydrationFromInput = true; // hydrates on updates
}
```

Expand Down

0 comments on commit 35ccdc2

Please sign in to comment.