@@ -40,7 +40,7 @@ $user->has_accepted_terms_and_conditions;
4040$user->accepted_terms_and_conditions_at;
4141
4242/*
43- * 2018-05-10 16:24:22 (string or Carbon instance)
43+ * 2018-05-10 16:24:22 (Carbon instance)
4444 */
4545```
4646
@@ -76,7 +76,7 @@ $user->accepted_terms_and_conditions_at;
7676composer require sebastiaanluca/laravel-boolean-dates
7777```
7878
79- ** Require the ` HasBooleanDates ` trait** in your Eloquent model, then add the ` $booleanDates ` and ` $dates ` (optional) fields :
79+ ** Require the ` HasBooleanDates ` trait** in your Eloquent model, then add the ` $booleanDates ` field :
8080
8181``` php
8282<?php
@@ -96,22 +96,9 @@ class User extends Model
9696 'allows_data_processing' => 'accepted_processing_at',
9797 'has_agreed_to_something' => 'agreed_to_something_at',
9898 ];
99-
100- /**
101- * The attributes that should be mutated to dates.
102- *
103- * @var array
104- */
105- protected $dates = [
106- 'accepted_terms_at',
107- 'accepted_processing_at',
108- 'agreed_to_something_at',
109- ];
11099}
111100```
112101
113- Adding the boolean date fields to the ` $dates ` array is ** optional** , but encouraged as it'll convert all your boolean datetimes to Carbon instances.
114-
115102To wrap up, create a ** migration** to create a new or alter your existing table and add the timestamp fields:
116103
117104``` php
@@ -210,7 +197,7 @@ $user = User::findOrFail(42);
210197$user->accepted_terms_at;
211198
212199/*
213- * 2018-05-10 16:24:22 (string or Carbon instance)
200+ * 2018-05-10 16:24:22 (Carbon instance)
214201 */
215202
216203$user->accepted_processing_at;
@@ -233,7 +220,7 @@ $user->toArray();
233220 * Which will return something like:
234221 *
235222 * [
236- * 'accepted_terms_at' => '2018-05-10 16:24:22',
223+ * 'accepted_terms_at' => \Carbon\Carbon( '2018-05-10 16:24:22') ,
237224 * 'accepted_processing_at' => NULL,
238225 * 'agreed_to_something_at' => \Carbon\Carbon('2018-05-10 16:24:22'),
239226 * 'accepted_terms_and_conditions' => true,
0 commit comments