You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trait for easy manage useful datetime in entities.
4
+
5
+
#### Usage
6
+
7
+
##### With Doctrine
8
+
9
+
1 - Add trait in your Entity
10
+
11
+
```php
12
+
<?php
13
+
14
+
use RedRat\Entity\DateTimeTrait;
15
+
16
+
class Foo
17
+
{
18
+
use DateTimeTrait;
19
+
}
20
+
```
21
+
22
+
2 - Set `lifecycleCallbacks` in your Doctrine configuration, like example below:
23
+
24
+
```yaml
25
+
lifecycleCallbacks:
26
+
prePersist: [ forgeCreatedAt ]
27
+
preUpdate: [ forgeUpdatedAt ]
28
+
```
29
+
30
+
Note: More about lifecycle callbacks in Doctrine [documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/events.html#lifecycle-callbacks).
0 commit comments