File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -66,3 +66,35 @@ getting as return/setAttribute of the field a string formated using the `to` key
6666The ` approved_at ` field in ` $dates ` array is still handled with the default behavior of the framework.
6767
6868** Note** that the input value of this fields - ` start_date ` and ` finish_date ` , must be in ` d/m/Y ` format.
69+
70+ ### Using Jenssegers/MongoDB
71+
72+ If you are using Jenssegers/MongoDB driver to persist date only, this trait can help you to handle
73+ MongoDB timestamp field type.
74+
75+ To ensure a date gonna be saved in UTC timezone at hour 00:00:00, you must add a ` date-only `
76+ setting in array ` $mapDateTimeMutator ` :
77+
78+ ``` php
79+ <?php
80+
81+ use Torzer\Common\Traits\MapDateTimeMutator;
82+
83+ class MyClass extends Jenssegers\Mongodb\Eloquent\Model {
84+
85+ use MapDateTimeMutator;
86+
87+ protected $mapDateTimeMutator = [
88+ 'start_date' => ['from' => 'd/m/Y', 'to' => 'Y-m-d'],
89+ 'finish_date' => ['from' => 'd/m/Y', 'to' => 'Y-m-d'],
90+ 'date-only' => true,
91+ ];
92+
93+ protected $dates = [
94+ 'approved_at', 'start_date', 'finish_date'
95+ ];
96+
97+ ...
98+
99+
100+ ```
You can’t perform that action at this time.
0 commit comments