Skip to content

Commit 629e871

Browse files
Merge branch 'release/0.1.0'
2 parents 8cdf412 + a4b34a9 commit 629e871

File tree

6 files changed

+21
-44
lines changed

6 files changed

+21
-44
lines changed

CHANGELOG.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,8 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## Unreleased
88

9-
## 0.2.0 (2018-07-26)
9+
## 0.1.0 (2018-07-26)
1010

1111
### Added
1212

13-
- Added a base Eloquent model
14-
- Added a queueable job
15-
- Added auto-discovery
16-
- Added a test suite and tests
17-
- Updated documents
18-
- Added boolean date parsing in base model
19-
- Add Laravel 5.6 service provider bindings and singletons properties
20-
- Alias all predefined class aliases
21-
- Map polymorphic models to their alias
22-
- Auto-register event listeners and subscribers
23-
- Added a call to a request handler's _before_ method
24-
25-
### Changed
26-
27-
- Require PHP 7.2 or higher
28-
- Require Laravel 5.6 or higher
29-
30-
### Removed
31-
32-
- Removed empty `mapRoutes` method
33-
- Removed empty `registerCommands` method
34-
- Removed empty `bindRepositories` method
35-
- Removed empty `mapMorphTypes` method
36-
- Removed empty `bootMiddleware` method
37-
- Extracted `BooleanDates` class to its own package
38-
39-
### Fixed
40-
41-
- Correctly resolve config file
13+
- Added BooleanDates model trait

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
Copyright (c) 2017 Sebastiaan Luca <hello@sebastiaanluca.com>
3+
Copyright (c) 2018 Sebastiaan Luca <hello@sebastiaanluca.com>
44

55
> Permission is hereby granted, free of charge, to any person obtaining a copy
66
> of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ Sets the date of fields to the current date and time if an inputted counterpart
1919
- [Requirements](#requirements)
2020
- [How to install](#how-to-install)
2121
- [How to use](#how-to-use)
22+
- [Saving dates](#saving-dates)
23+
- [Clearing saved values](#clearing-saved-values)
24+
- [Retrieving values](#retrieving-values)
25+
- [Retrieving fields as booleans](#retrieving-fields-as-booleans)
26+
- [Retrieving fields as datetimes](#retrieving-fields-as-datetimes)
27+
- [Array conversion](#array-conversion)
2228
- [License](#license)
2329
- [Change log](#change-log)
2430
- [Testing](#testing)
@@ -95,7 +101,7 @@ $user->fill([
95101
$user->save();
96102
```
97103

98-
When you now check your database, all fields should contain a datetime similar to `2018-05-10 16:24:22`.
104+
All fields should now contain a datetime similar to `2018-05-10 16:24:22`.
99105

100106
### Clearing saved values
101107

@@ -109,7 +115,7 @@ $user->allows_data_processing = false;
109115
$user->save();
110116
```
111117

112-
False values will be converted to `NULL` in your database.
118+
False values are converted to `NULL`.
113119

114120
### Retrieving values
115121

@@ -118,8 +124,6 @@ False values will be converted to `NULL` in your database.
118124
Use a boolean field's defined _key_ to access its boolean value:
119125

120126
```php
121-
<?php
122-
123127
$user = User::findOrFail(42);
124128

125129
$user->has_accepted_terms_and_conditions;
@@ -146,8 +150,6 @@ $user->has_agreed_to_something;
146150
Use a boolean field's defined _value_ to explicitly access its (Carbon) datetime value:
147151

148152
```php
149-
<?php
150-
151153
$user = User::findOrFail(42);
152154

153155
$user->accepted_terms_at;

src/BooleanDates.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getAttribute($key)
4646
}
4747

4848
if ($this->hasBooleanDate($key)) {
49-
return ! is_null($this->attributes[$this->getBooleanDateField($key)]);
49+
return $this->attributes[$this->getBooleanDateField($key)] !== null;
5050
}
5151

5252
return parent::getAttribute($key);
@@ -60,7 +60,7 @@ public function getAttribute($key)
6060
*
6161
* @return $this
6262
*/
63-
public function setAttribute($key, $value)
63+
public function setAttribute($key, $value) : self
6464
{
6565
if ($this->hasBooleanDate($key)) {
6666
$this->setBooleanDate($key, $value);
@@ -124,7 +124,7 @@ public function currentBooleanDateFieldValueIsNotYetSet(string $key) : bool
124124
return true;
125125
}
126126

127-
return is_null($this->attributes[$this->getBooleanDateField($key)]);
127+
return $this->attributes[$this->getBooleanDateField($key)] === null;
128128
}
129129

130130
/**
@@ -159,7 +159,7 @@ protected function addBooleanDateAttributesToArray(array $attributes) : array
159159
continue;
160160
}
161161

162-
$attributes[$booleanField] = ! is_null($date);
162+
$attributes[$booleanField] = $date !== null;
163163
}
164164

165165
return $attributes;

src/BooleanDatesServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace SebastiaanLuca\BooleanDates;
66

7-
class BooleanDatesServiceProvider extends Provider
7+
use Illuminate\Support\ServiceProvider;
8+
9+
class BooleanDatesServiceProvider extends ServiceProvider
810
{
911
}

tests/TestCase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SebastiaanLuca\BooleanDates\Tests;
44

55
use Orchestra\Testbench\TestCase as BaseTestCase;
6+
use SebastiaanLuca\BooleanDates\BooleanDatesServiceProvider;
67

78
class TestCase extends BaseTestCase
89
{
@@ -11,10 +12,10 @@ class TestCase extends BaseTestCase
1112
*
1213
* @return array
1314
*/
14-
protected function getPackageProviders($app)
15+
protected function getPackageProviders($app) : array
1516
{
1617
return [
17-
//
18+
BooleanDatesServiceProvider::class,
1819
];
1920
}
2021
}

0 commit comments

Comments
 (0)