1 | <?php |
||
2 | |||
3 | namespace Isswp101\Persimmon\Concerns; |
||
4 | |||
5 | use DateTime; |
||
6 | |||
7 | trait Timestampable |
||
8 | { |
||
9 | protected bool $timestamps = true; |
||
10 | |||
11 | private function touch(bool $exists): void |
||
12 | { |
||
13 | if (!$this->timestamps) { |
||
14 | return; |
||
15 | } |
||
16 | |||
17 | $dt = new DateTime(); |
||
18 | |||
19 | $now = $dt->format(DateTime::ISO8601); |
||
20 | |||
21 | $this->created_at = !$exists ? $now : $this->created_at; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
22 | $this->updated_at = $now; |
||
0 ignored issues
–
show
|
|||
23 | } |
||
24 | } |
||
25 |