Skip to content

Commit 48dcb65

Browse files
authored
Add Laravel 5.8 support (#46)
* Add Laravel 5.8 support * Add methods return types * Drop PHP 5.6 & PHP 7.0 support * Use Support Carbon
1 parent ce5ac87 commit 48dcb65

File tree

218 files changed

+1174
-755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+1174
-755
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
64
- 7.1
75
- 7.2
86
- 7.3

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
All notable changes to `laravel-eloquent-flag` will be documented in this file.
44

5+
## [5.0.0] - WIP
6+
7+
### Added
8+
9+
- Laravel 5.8 support
10+
11+
### Changed
12+
13+
- All methods are strict typed now
14+
- `Carbon\Carbon` replaced with `Illuminate\Support\Carbon`
15+
16+
### Removed
17+
18+
- PHP 5.6, 7.0 support
19+
- Laravel 5.2, 5.3, 5.4 support
20+
521
## [4.0.0] - 2018-09-09
622

723
### Added
@@ -172,6 +188,7 @@ All notable changes to `laravel-eloquent-flag` will be documented in this file.
172188

173189
- `is_active` boolean flag added.
174190

191+
[5.0.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/4.0.0...v5.0.0
175192
[4.0.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/3.13.0...4.0.0
176193
[3.13.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/3.12.0...3.13.0
177194
[3.12.0]: https://github.com/cybercog/laravel-eloquent-flag/compare/3.11.0...3.12.0

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
![cog-laravel-eloquent-flag-3](https://cloud.githubusercontent.com/assets/1849174/21735581/feb857cc-d47b-11e6-80fa-126be1a1d871.png)
1+
# Laravel Eloquent Flag
2+
3+
![cog-laravel-eloquent-flag](https://user-images.githubusercontent.com/1849174/53454214-7d38d680-3a37-11e9-953d-8daee98fb087.png)
24

35
<p align="center">
46
<a href="https://github.com/cybercog/laravel-eloquent-flag/releases"><img src="https://img.shields.io/github/release/cybercog/laravel-eloquent-flag.svg?style=flat-square" alt="Releases"></a>
@@ -10,7 +12,7 @@
1012

1113
## Introduction
1214

13-
Eloquent boolean & timestamp flagged attributes behavior. Enhance eloquent models with commonly used state flags like `Active`, `Published`, `Approved` and others in a minutes!
15+
Eloquent boolean & timestamp flagged attributes behavior. Enhance Eloquent Models with commonly used state flags like `Active`, `Published`, `Approved` and others in a minutes!
1416

1517
## Contents
1618

@@ -32,7 +34,7 @@ Eloquent boolean & timestamp flagged attributes behavior. Enhance eloquent model
3234
## Features
3335

3436
- Designed to work with Laravel Eloquent models.
35-
- Each model can has as many flags as required.
37+
- Each model can has many flags.
3638
- Each flag adds global query scopes to models.
3739
- 2 logical groups of flags: `Classic`, `Inverse`.
3840
- 2 types of flags: `Boolean`, `Timestamp`.
@@ -134,15 +136,12 @@ If you discover any security related issues, please email open@cybercog.su inste
134136

135137
## Alternatives
136138

137-
*Not found.*
138-
139139
*Feel free to add more alternatives as Pull Request.*
140140

141141
## License
142142

143-
- `Laravel Eloquent Flag` package is open-sourced software licensed under the [MIT license](LICENSE) by Anton Komarev.
144-
- `Check Mark` image licensed under [Creative Commons 3.0](https://creativecommons.org/licenses/by/3.0/us/) by Kimmi Studio.
145-
- `Clock Check` image licensed under [Creative Commons 3.0](https://creativecommons.org/licenses/by/3.0/us/) by Harsha Rai.
143+
- `Laravel Eloquent Flag` package is open-sourced software licensed under the [MIT license](LICENSE) by [Anton Komarev](https://github.com/antonkomarev).
144+
- `Clock` image licensed under [Creative Commons 3.0](https://creativecommons.org/licenses/by/3.0/us/) by Rudez Studio.
146145

147146
## About CyberCog
148147

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"docs": "https://github.com/cybercog/laravel-eloquent-flag/wiki"
5454
},
5555
"require": {
56-
"php": "^5.6|^7.0",
57-
"illuminate/database": "5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*"
56+
"php": "^7.1.3",
57+
"illuminate/database": "5.5.*|5.6.*|5.7.*|5.8.*"
5858
},
5959
"require-dev": {
6060
"friendsofphp/php-cs-fixer": "^2.10",
6161
"mockery/mockery": "^1.0",
62-
"orchestra/database": "~3.4.0|~3.5.0|~3.6.0|~3.7.0",
63-
"orchestra/testbench": "~3.4.0|~3.5.0|~3.6.0|~3.7.0",
62+
"orchestra/database": "~3.5.0|~3.6.0|~3.7.0|~3.8.0",
63+
"orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0|~3.8.0",
6464
"phpunit/phpunit": "^5.7|^6.2|^7.0|^8.0"
6565
},
6666
"autoload": {

src/Providers/FlagServiceProvider.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Scopes/Classic/AcceptedAtScope.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace Cog\Flag\Scopes\Classic;
1315

14-
use Carbon\Carbon;
1516
use Illuminate\Database\Eloquent\Builder;
1617
use Illuminate\Database\Eloquent\Model;
1718
use Illuminate\Database\Eloquent\Scope;
19+
use Illuminate\Support\Carbon;
1820

1921
class AcceptedAtScope implements Scope
2022
{
@@ -36,11 +38,11 @@ class AcceptedAtScope implements Scope
3638
*
3739
* @param \Illuminate\Database\Eloquent\Builder $builder
3840
* @param \Illuminate\Database\Eloquent\Model $model
39-
* @return \Illuminate\Database\Eloquent\Builder
41+
* @return void
4042
*/
41-
public function apply(Builder $builder, Model $model)
43+
public function apply(Builder $builder, Model $model): void
4244
{
43-
return $builder->whereNotNull('accepted_at');
45+
$builder->whereNotNull('accepted_at');
4446
}
4547

4648
/**
@@ -49,7 +51,7 @@ public function apply(Builder $builder, Model $model)
4951
* @param \Illuminate\Database\Eloquent\Builder $builder
5052
* @return void
5153
*/
52-
public function extend(Builder $builder)
54+
public function extend(Builder $builder): void
5355
{
5456
foreach ($this->extensions as $extension) {
5557
$this->{"add{$extension}"}($builder);
@@ -62,7 +64,7 @@ public function extend(Builder $builder)
6264
* @param \Illuminate\Database\Eloquent\Builder $builder
6365
* @return void
6466
*/
65-
protected function addAccept(Builder $builder)
67+
protected function addAccept(Builder $builder): void
6668
{
6769
$builder->macro('accept', function (Builder $builder) {
6870
$builder->withRejected();
@@ -77,7 +79,7 @@ protected function addAccept(Builder $builder)
7779
* @param \Illuminate\Database\Eloquent\Builder $builder
7880
* @return void
7981
*/
80-
protected function addReject(Builder $builder)
82+
protected function addReject(Builder $builder): void
8183
{
8284
$builder->macro('reject', function (Builder $builder) {
8385
return $builder->update(['accepted_at' => null]);
@@ -90,7 +92,7 @@ protected function addReject(Builder $builder)
9092
* @param \Illuminate\Database\Eloquent\Builder $builder
9193
* @return void
9294
*/
93-
protected function addWithRejected(Builder $builder)
95+
protected function addWithRejected(Builder $builder): void
9496
{
9597
$builder->macro('withRejected', function (Builder $builder) {
9698
return $builder->withoutGlobalScope($this);
@@ -103,7 +105,7 @@ protected function addWithRejected(Builder $builder)
103105
* @param \Illuminate\Database\Eloquent\Builder $builder
104106
* @return void
105107
*/
106-
protected function addWithoutRejected(Builder $builder)
108+
protected function addWithoutRejected(Builder $builder): void
107109
{
108110
$builder->macro('withoutRejected', function (Builder $builder) {
109111
return $builder->withoutGlobalScope($this)->whereNotNull('accepted_at');
@@ -116,7 +118,7 @@ protected function addWithoutRejected(Builder $builder)
116118
* @param \Illuminate\Database\Eloquent\Builder $builder
117119
* @return void
118120
*/
119-
protected function addOnlyRejected(Builder $builder)
121+
protected function addOnlyRejected(Builder $builder): void
120122
{
121123
$builder->macro('onlyRejected', function (Builder $builder) {
122124
return $builder->withoutGlobalScope($this)->whereNull('accepted_at');

src/Scopes/Classic/AcceptedFlagScope.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace Cog\Flag\Scopes\Classic;
1315

1416
use Illuminate\Database\Eloquent\Builder;
@@ -35,11 +37,11 @@ class AcceptedFlagScope implements Scope
3537
*
3638
* @param \Illuminate\Database\Eloquent\Builder $builder
3739
* @param \Illuminate\Database\Eloquent\Model $model
38-
* @return \Illuminate\Database\Eloquent\Builder
40+
* @return void
3941
*/
40-
public function apply(Builder $builder, Model $model)
42+
public function apply(Builder $builder, Model $model): void
4143
{
42-
return $builder->where('is_accepted', 1);
44+
$builder->where('is_accepted', 1);
4345
}
4446

4547
/**
@@ -48,7 +50,7 @@ public function apply(Builder $builder, Model $model)
4850
* @param \Illuminate\Database\Eloquent\Builder $builder
4951
* @return void
5052
*/
51-
public function extend(Builder $builder)
53+
public function extend(Builder $builder): void
5254
{
5355
foreach ($this->extensions as $extension) {
5456
$this->{"add{$extension}"}($builder);
@@ -61,7 +63,7 @@ public function extend(Builder $builder)
6163
* @param \Illuminate\Database\Eloquent\Builder $builder
6264
* @return void
6365
*/
64-
protected function addAccept(Builder $builder)
66+
protected function addAccept(Builder $builder): void
6567
{
6668
$builder->macro('accept', function (Builder $builder) {
6769
$builder->withRejected();
@@ -76,7 +78,7 @@ protected function addAccept(Builder $builder)
7678
* @param \Illuminate\Database\Eloquent\Builder $builder
7779
* @return void
7880
*/
79-
protected function addReject(Builder $builder)
81+
protected function addReject(Builder $builder): void
8082
{
8183
$builder->macro('reject', function (Builder $builder) {
8284
return $builder->update(['is_accepted' => 0]);
@@ -89,7 +91,7 @@ protected function addReject(Builder $builder)
8991
* @param \Illuminate\Database\Eloquent\Builder $builder
9092
* @return void
9193
*/
92-
protected function addWithRejected(Builder $builder)
94+
protected function addWithRejected(Builder $builder): void
9395
{
9496
$builder->macro('withRejected', function (Builder $builder) {
9597
return $builder->withoutGlobalScope($this);
@@ -102,7 +104,7 @@ protected function addWithRejected(Builder $builder)
102104
* @param \Illuminate\Database\Eloquent\Builder $builder
103105
* @return void
104106
*/
105-
protected function addWithoutRejected(Builder $builder)
107+
protected function addWithoutRejected(Builder $builder): void
106108
{
107109
$builder->macro('withoutRejected', function (Builder $builder) {
108110
return $builder->withoutGlobalScope($this)->where('is_accepted', 1);
@@ -115,7 +117,7 @@ protected function addWithoutRejected(Builder $builder)
115117
* @param \Illuminate\Database\Eloquent\Builder $builder
116118
* @return void
117119
*/
118-
protected function addOnlyRejected(Builder $builder)
120+
protected function addOnlyRejected(Builder $builder): void
119121
{
120122
$builder->macro('onlyRejected', function (Builder $builder) {
121123
return $builder->withoutGlobalScope($this)->where('is_accepted', 0);

src/Scopes/Classic/ActiveFlagScope.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace Cog\Flag\Scopes\Classic;
1315

1416
use Illuminate\Database\Eloquent\Builder;
@@ -35,11 +37,11 @@ class ActiveFlagScope implements Scope
3537
*
3638
* @param \Illuminate\Database\Eloquent\Builder $builder
3739
* @param \Illuminate\Database\Eloquent\Model $model
38-
* @return \Illuminate\Database\Eloquent\Builder
40+
* @return void
3941
*/
40-
public function apply(Builder $builder, Model $model)
42+
public function apply(Builder $builder, Model $model): void
4143
{
42-
return $builder->where('is_active', 1);
44+
$builder->where('is_active', 1);
4345
}
4446

4547
/**
@@ -48,7 +50,7 @@ public function apply(Builder $builder, Model $model)
4850
* @param \Illuminate\Database\Eloquent\Builder $builder
4951
* @return void
5052
*/
51-
public function extend(Builder $builder)
53+
public function extend(Builder $builder): void
5254
{
5355
foreach ($this->extensions as $extension) {
5456
$this->{"add{$extension}"}($builder);
@@ -61,7 +63,7 @@ public function extend(Builder $builder)
6163
* @param \Illuminate\Database\Eloquent\Builder $builder
6264
* @return void
6365
*/
64-
protected function addActivate(Builder $builder)
66+
protected function addActivate(Builder $builder): void
6567
{
6668
$builder->macro('activate', function (Builder $builder) {
6769
$builder->withDeactivated();
@@ -76,7 +78,7 @@ protected function addActivate(Builder $builder)
7678
* @param \Illuminate\Database\Eloquent\Builder $builder
7779
* @return void
7880
*/
79-
protected function addDeactivate(Builder $builder)
81+
protected function addDeactivate(Builder $builder): void
8082
{
8183
$builder->macro('deactivate', function (Builder $builder) {
8284
return $builder->update(['is_active' => 0]);
@@ -89,7 +91,7 @@ protected function addDeactivate(Builder $builder)
8991
* @param \Illuminate\Database\Eloquent\Builder $builder
9092
* @return void
9193
*/
92-
protected function addWithDeactivated(Builder $builder)
94+
protected function addWithDeactivated(Builder $builder): void
9395
{
9496
$builder->macro('withDeactivated', function (Builder $builder) {
9597
return $builder->withoutGlobalScope($this);
@@ -102,7 +104,7 @@ protected function addWithDeactivated(Builder $builder)
102104
* @param \Illuminate\Database\Eloquent\Builder $builder
103105
* @return void
104106
*/
105-
protected function addWithoutDeactivated(Builder $builder)
107+
protected function addWithoutDeactivated(Builder $builder): void
106108
{
107109
$builder->macro('withoutDeactivated', function (Builder $builder) {
108110
return $builder->withoutGlobalScope($this)->where('is_active', 1);
@@ -115,7 +117,7 @@ protected function addWithoutDeactivated(Builder $builder)
115117
* @param \Illuminate\Database\Eloquent\Builder $builder
116118
* @return void
117119
*/
118-
protected function addOnlyDeactivated(Builder $builder)
120+
protected function addOnlyDeactivated(Builder $builder): void
119121
{
120122
$builder->macro('onlyDeactivated', function (Builder $builder) {
121123
return $builder->withoutGlobalScope($this)->where('is_active', 0);

0 commit comments

Comments
 (0)