-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbdcb9e
commit 522f8a7
Showing
1 changed file
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,34 @@ | ||
# entity-datetime | ||
# Entity datetime | ||
|
||
Trait for easy manage useful datetime in entities. | ||
|
||
#### Usage | ||
|
||
##### With Doctrine | ||
|
||
1 - Add trait in your Entity | ||
|
||
```php | ||
<?php | ||
|
||
use RedRat\Entity\DateTimeTrait; | ||
|
||
class Foo | ||
{ | ||
use DateTimeTrait; | ||
} | ||
``` | ||
|
||
2 - Set `lifecycleCallbacks` in your Doctrine configuration, like example below: | ||
|
||
```yaml | ||
lifecycleCallbacks: | ||
prePersist: [ forgeCreatedAt ] | ||
preUpdate: [ forgeUpdatedAt ] | ||
``` | ||
Note: More about lifecycle callbacks in Doctrine [documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/events.html#lifecycle-callbacks). | ||
#### TODO | ||
* API documentation. |