Skip to content

Commit 6567283

Browse files
Update readme
1 parent 4c9b716 commit 6567283

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Easily convert Eloquent model booleans to dates and back
1+
# Easily convert Eloquent model boolean fields to dates and back
22

33
[![Latest stable release][version-badge]][link-packagist]
44
[![Software license][license-badge]](LICENSE.md)
@@ -76,7 +76,7 @@ class User extends Model
7676
}
7777
```
7878

79-
Adding the boolean dates _values_ to the `$dates` array is optional, but encouraged as it'll convert all your boolean datetimes to Carbon instances.
79+
Adding the boolean dates _values_ to the `$dates` array is **optional**, but encouraged as it'll convert all your boolean datetimes to Carbon instances.
8080

8181
## How to use
8282

@@ -108,12 +108,18 @@ Of course you can also remove the saved date and time, for instance if a user re
108108
```php
109109
$user = User::findOrFail(42);
110110

111-
$user->allows_data_processing = false;
111+
$user->has_accepted_terms_and_conditions = false;
112+
// $user->has_accepted_terms_and_conditions = null;
113+
114+
$user->allows_data_processing = 0;
115+
// $user->allows_data_processing = '0';
116+
117+
$user->has_agreed_to_something = '';
112118

113119
$user->save();
114120
```
115121

116-
False values are converted to `NULL`.
122+
False or false-y values are converted to `NULL`.
117123

118124
### Retrieving values
119125

@@ -127,19 +133,7 @@ $user = User::findOrFail(42);
127133
$user->has_accepted_terms_and_conditions;
128134

129135
/*
130-
* true (boolean)
131-
*/
132-
133-
$user->allows_data_processing;
134-
135-
/*
136-
* false (boolean)
137-
*/
138-
139-
$user->has_agreed_to_something;
140-
141-
/*
142-
* true (boolean)
136+
* true or false (boolean)
143137
*/
144138
```
145139

@@ -161,12 +155,6 @@ $user->accepted_processing_at;
161155
/*
162156
* NULL
163157
*/
164-
165-
$user->agreed_to_something_at;
166-
167-
/*
168-
* 2018-05-10 16:24:22 (string or Carbon instance)
169-
*/
170158
```
171159

172160
### Array conversion
@@ -179,10 +167,10 @@ $user = User::findOrFail(42);
179167
$user->toArray();
180168

181169
/*
182-
* Which will return:
170+
* Which will return something like:
183171
*
184172
* [
185-
* 'accepted_terms_at' => \Carbon\Carbon('2018-05-10 16:24:22'),
173+
* 'accepted_terms_at' => '2018-05-10 16:24:22',
186174
* 'accepted_processing_at' => NULL,
187175
* 'agreed_to_something_at' => \Carbon\Carbon('2018-05-10 16:24:22'),
188176
* 'accepted_terms_and_conditions' => true,

0 commit comments

Comments
 (0)