Skip to content

Commit e9cc448

Browse files
authored
Rename scope methods (#54)
Rename global scopes methods
1 parent ae3e5c2 commit e9cc448

Some content is hidden

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

45 files changed

+429
-396
lines changed

CHANGELOG.md

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,63 @@ All notable changes to `laravel-eloquent-flag` will be documented in this file.
1313

1414
- All methods are strict typed now
1515
- `Carbon\Carbon` replaced with `Illuminate\Support\Facades\Date`
16-
- `isRejected` method renamed to `isNotAccepted`
17-
- `isDeactivated` method renamed to `isNotActivated`
18-
- `isDisapproved` method renamed to `isNotApproved`
19-
- `isUninvited` method renamed to `isNotInvited`
20-
- `isUnkept` method renamed to `isNotKept`
21-
- `isUnpublished` method renamed to `isNotPublished`
22-
- `isUnverified` method renamed to `isNotVerified`
23-
- `isUnarchived` method renamed to `isNotArchived`
24-
- `isOpened` method renamed to `isNotClosed`
25-
- `isUndrafted` method renamed to `isNotDrafted`
26-
- `isUnended` method renamed to `isNotEnded`
27-
- `isUnexpired` method renamed to `isNotExpired`
28-
- `reject` method renamed to `undoAccept`
29-
- `deactivate` method renamed to `undoActivate`
30-
- `disapprove` method renamed to `undoApprove`
31-
- `uninvite` method renamed to `undoInvite`
32-
- `unkeep` method renamed to `undoKeep`
33-
- `unpublish` method renamed to `undoPublish`
34-
- `unverify` method renamed to `undoVerify`
35-
- `unarchive` method renamed to `undoArchive`
36-
- `open` method renamed to `undoClose`
37-
- `undraft` method renamed to `undoDraft`
38-
- `unend` method renamed to `undoEnd`
39-
- `unexpire` method renamed to `undoExpire`
16+
- `isRejected` instance method renamed to `isNotAccepted`
17+
- `isDeactivated` instance method renamed to `isNotActivated`
18+
- `isDisapproved` instance method renamed to `isNotApproved`
19+
- `isUninvited` instance method renamed to `isNotInvited`
20+
- `isUnkept` instance method renamed to `isNotKept`
21+
- `isUnpublished` instance method renamed to `isNotPublished`
22+
- `isUnverified` instance method renamed to `isNotVerified`
23+
- `isUnarchived` instance method renamed to `isNotArchived`
24+
- `isOpened` instance method renamed to `isNotClosed`
25+
- `isUndrafted` instance method renamed to `isNotDrafted`
26+
- `isUnended` instance method renamed to `isNotEnded`
27+
- `isUnexpired` instance method renamed to `isNotExpired`
28+
- `reject` instance method renamed to `undoAccept`
29+
- `deactivate` instance method renamed to `undoActivate`
30+
- `disapprove` instance method renamed to `undoApprove`
31+
- `uninvite` instance method renamed to `undoInvite`
32+
- `unkeep` instance method renamed to `undoKeep`
33+
- `unpublish` instance method renamed to `undoPublish`
34+
- `unverify` instance method renamed to `undoVerify`
35+
- `unarchive` instance method renamed to `undoArchive`
36+
- `open` instance method renamed to `undoClose`
37+
- `undraft` instance method renamed to `undoDraft`
38+
- `unend` instance method renamed to `undoEnd`
39+
- `unexpire` instance method renamed to `undoExpire`
40+
- `reject` global scope method renamed to `undoAccept`
41+
- `withRejected` global scope method renamed to `withNotAccepted`
42+
- `withoutRejected` global scope method renamed to `withoutNotAccepted`
43+
- `onlyRejected` global scope method renamed to `onlyNotAccepted`
44+
- `deactivate` global scope method renamed to `undoActivate`
45+
- `withDeactivated` global scope method renamed to `withNotActivated`
46+
- `withoutDeactivated` global scope method renamed to `withoutNotActivated`
47+
- `onlyDeactivated` global scope method renamed to `onlyNotActivated`
48+
- `disapprove` global scope method renamed to `undoApprove`
49+
- `withDisapproved` global scope method renamed to `withNotApproved`
50+
- `withoutDisapproved` global scope method renamed to `withoutNotApproved`
51+
- `onlyDisapproved` global scope method renamed to `onlyNotApproved`
52+
- `uninvite` global scope method renamed to `undoInvite`
53+
- `withUninvited` global scope method renamed to `withNotInvited`
54+
- `withoutUninvited` global scope method renamed to `withoutNotInvited`
55+
- `onlyUninvited` global scope method renamed to `onlyNotInvited`
56+
- `unkeep` global scope method renamed to `undoKeep`
57+
- `withUnkept` global scope method renamed to `withNotKept`
58+
- `withoutUnkept` global scope method renamed to `withoutNotKept`
59+
- `onlyUnkept` global scope method renamed to `onlyNotKept`
60+
- `unpublish` global scope method renamed to `undoPublish`
61+
- `withUnpublished` global scope method renamed to `withNotPublished`
62+
- `withoutUnpublished` global scope method renamed to `withoutNotPublished`
63+
- `onlyUnpublished` global scope method renamed to `onlyNotPublished`
64+
- `unverify` global scope method renamed to `undoVerify`
65+
- `withUnverified` global scope method renamed to `withNotVerified`
66+
- `withoutUnverified` global scope method renamed to `withoutNotVerified`
67+
- `onlyUnverified` global scope method renamed to `onlyNotVerified`
68+
- `unarchive` global scope method renamed to `undoArchive`
69+
- `open` global scope method renamed to `undoClose`
70+
- `undraft` global scope method renamed to `undoDraft`
71+
- `unend` global scope method renamed to `undoEnd`
72+
- `unexpire` global scope method renamed to `undoExpire`
4073

4174
### Removed
4275

src/Scopes/Classic/AcceptedAtScope.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ final class AcceptedAtScope implements Scope
2727
*/
2828
protected $extensions = [
2929
'Accept',
30-
'Reject',
31-
'WithRejected',
32-
'WithoutRejected',
33-
'OnlyRejected',
30+
'UndoAccept',
31+
'WithNotAccepted',
32+
'WithoutNotAccepted',
33+
'OnlyNotAccepted',
3434
];
3535

3636
/**
@@ -67,60 +67,60 @@ public function extend(Builder $builder): void
6767
protected function addAccept(Builder $builder): void
6868
{
6969
$builder->macro('accept', function (Builder $builder) {
70-
$builder->withRejected();
70+
$builder->withNotAccepted();
7171

7272
return $builder->update(['accepted_at' => Date::now()]);
7373
});
7474
}
7575

7676
/**
77-
* Add the `reject` extension to the builder.
77+
* Add the `undoAccept` extension to the builder.
7878
*
7979
* @param \Illuminate\Database\Eloquent\Builder $builder
8080
* @return void
8181
*/
82-
protected function addReject(Builder $builder): void
82+
protected function addUndoAccept(Builder $builder): void
8383
{
84-
$builder->macro('reject', function (Builder $builder) {
84+
$builder->macro('undoAccept', function (Builder $builder) {
8585
return $builder->update(['accepted_at' => null]);
8686
});
8787
}
8888

8989
/**
90-
* Add the `withRejected` extension to the builder.
90+
* Add the `withNotAccepted` extension to the builder.
9191
*
9292
* @param \Illuminate\Database\Eloquent\Builder $builder
9393
* @return void
9494
*/
95-
protected function addWithRejected(Builder $builder): void
95+
protected function addWithNotAccepted(Builder $builder): void
9696
{
97-
$builder->macro('withRejected', function (Builder $builder) {
97+
$builder->macro('withNotAccepted', function (Builder $builder) {
9898
return $builder->withoutGlobalScope($this);
9999
});
100100
}
101101

102102
/**
103-
* Add the `withoutRejected` extension to the builder.
103+
* Add the `withoutNotAccepted` extension to the builder.
104104
*
105105
* @param \Illuminate\Database\Eloquent\Builder $builder
106106
* @return void
107107
*/
108-
protected function addWithoutRejected(Builder $builder): void
108+
protected function addWithoutNotAccepted(Builder $builder): void
109109
{
110-
$builder->macro('withoutRejected', function (Builder $builder) {
110+
$builder->macro('withoutNotAccepted', function (Builder $builder) {
111111
return $builder->withoutGlobalScope($this)->whereNotNull('accepted_at');
112112
});
113113
}
114114

115115
/**
116-
* Add the `onlyRejected` extension to the builder.
116+
* Add the `onlyNotAccepted` extension to the builder.
117117
*
118118
* @param \Illuminate\Database\Eloquent\Builder $builder
119119
* @return void
120120
*/
121-
protected function addOnlyRejected(Builder $builder): void
121+
protected function addOnlyNotAccepted(Builder $builder): void
122122
{
123-
$builder->macro('onlyRejected', function (Builder $builder) {
123+
$builder->macro('onlyNotAccepted', function (Builder $builder) {
124124
return $builder->withoutGlobalScope($this)->whereNull('accepted_at');
125125
});
126126
}

src/Scopes/Classic/AcceptedFlagScope.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ final class AcceptedFlagScope implements Scope
2626
*/
2727
protected $extensions = [
2828
'Accept',
29-
'Reject',
30-
'WithRejected',
31-
'WithoutRejected',
32-
'OnlyRejected',
29+
'UndoAccept',
30+
'WithNotAccepted',
31+
'WithoutNotAccepted',
32+
'OnlyNotAccepted',
3333
];
3434

3535
/**
@@ -66,60 +66,60 @@ public function extend(Builder $builder): void
6666
protected function addAccept(Builder $builder): void
6767
{
6868
$builder->macro('accept', function (Builder $builder) {
69-
$builder->withRejected();
69+
$builder->withNotAccepted();
7070

7171
return $builder->update(['is_accepted' => 1]);
7272
});
7373
}
7474

7575
/**
76-
* Add the `reject` extension to the builder.
76+
* Add the `undoAccept` extension to the builder.
7777
*
7878
* @param \Illuminate\Database\Eloquent\Builder $builder
7979
* @return void
8080
*/
81-
protected function addReject(Builder $builder): void
81+
protected function addUndoAccept(Builder $builder): void
8282
{
83-
$builder->macro('reject', function (Builder $builder) {
83+
$builder->macro('undoAccept', function (Builder $builder) {
8484
return $builder->update(['is_accepted' => 0]);
8585
});
8686
}
8787

8888
/**
89-
* Add the `withRejected` extension to the builder.
89+
* Add the `withNotAccepted` extension to the builder.
9090
*
9191
* @param \Illuminate\Database\Eloquent\Builder $builder
9292
* @return void
9393
*/
94-
protected function addWithRejected(Builder $builder): void
94+
protected function addWithNotAccepted(Builder $builder): void
9595
{
96-
$builder->macro('withRejected', function (Builder $builder) {
96+
$builder->macro('withNotAccepted', function (Builder $builder) {
9797
return $builder->withoutGlobalScope($this);
9898
});
9999
}
100100

101101
/**
102-
* Add the `withoutRejected` extension to the builder.
102+
* Add the `withoutNotAccepted` extension to the builder.
103103
*
104104
* @param \Illuminate\Database\Eloquent\Builder $builder
105105
* @return void
106106
*/
107-
protected function addWithoutRejected(Builder $builder): void
107+
protected function addWithoutNotAccepted(Builder $builder): void
108108
{
109-
$builder->macro('withoutRejected', function (Builder $builder) {
109+
$builder->macro('withoutNotAccepted', function (Builder $builder) {
110110
return $builder->withoutGlobalScope($this)->where('is_accepted', 1);
111111
});
112112
}
113113

114114
/**
115-
* Add the `onlyRejected` extension to the builder.
115+
* Add the `onlyNotAccepted` extension to the builder.
116116
*
117117
* @param \Illuminate\Database\Eloquent\Builder $builder
118118
* @return void
119119
*/
120-
protected function addOnlyRejected(Builder $builder): void
120+
protected function addOnlyNotAccepted(Builder $builder): void
121121
{
122-
$builder->macro('onlyRejected', function (Builder $builder) {
122+
$builder->macro('onlyNotAccepted', function (Builder $builder) {
123123
return $builder->withoutGlobalScope($this)->where('is_accepted', 0);
124124
});
125125
}

src/Scopes/Classic/ActiveFlagScope.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ final class ActiveFlagScope implements Scope
2626
*/
2727
protected $extensions = [
2828
'Activate',
29-
'Deactivate',
30-
'WithDeactivated',
31-
'WithoutDeactivated',
32-
'OnlyDeactivated',
29+
'UndoActivate',
30+
'WithNotActivated',
31+
'WithoutNotActivated',
32+
'OnlyNotActivated',
3333
];
3434

3535
/**
@@ -66,60 +66,60 @@ public function extend(Builder $builder): void
6666
protected function addActivate(Builder $builder): void
6767
{
6868
$builder->macro('activate', function (Builder $builder) {
69-
$builder->withDeactivated();
69+
$builder->withNotActivated();
7070

7171
return $builder->update(['is_active' => 1]);
7272
});
7373
}
7474

7575
/**
76-
* Add the `deactivate` extension to the builder.
76+
* Add the `undoActivate` extension to the builder.
7777
*
7878
* @param \Illuminate\Database\Eloquent\Builder $builder
7979
* @return void
8080
*/
81-
protected function addDeactivate(Builder $builder): void
81+
protected function addUndoActivate(Builder $builder): void
8282
{
83-
$builder->macro('deactivate', function (Builder $builder) {
83+
$builder->macro('undoActivate', function (Builder $builder) {
8484
return $builder->update(['is_active' => 0]);
8585
});
8686
}
8787

8888
/**
89-
* Add the `withDeactivated` extension to the builder.
89+
* Add the `withNotActivated` extension to the builder.
9090
*
9191
* @param \Illuminate\Database\Eloquent\Builder $builder
9292
* @return void
9393
*/
94-
protected function addWithDeactivated(Builder $builder): void
94+
protected function addWithNotActivated(Builder $builder): void
9595
{
96-
$builder->macro('withDeactivated', function (Builder $builder) {
96+
$builder->macro('withNotActivated', function (Builder $builder) {
9797
return $builder->withoutGlobalScope($this);
9898
});
9999
}
100100

101101
/**
102-
* Add the `withoutDeactivated` extension to the builder.
102+
* Add the `withoutNotActivated` extension to the builder.
103103
*
104104
* @param \Illuminate\Database\Eloquent\Builder $builder
105105
* @return void
106106
*/
107-
protected function addWithoutDeactivated(Builder $builder): void
107+
protected function addWithoutNotActivated(Builder $builder): void
108108
{
109-
$builder->macro('withoutDeactivated', function (Builder $builder) {
109+
$builder->macro('withoutNotActivated', function (Builder $builder) {
110110
return $builder->withoutGlobalScope($this)->where('is_active', 1);
111111
});
112112
}
113113

114114
/**
115-
* Add the `onlyDeactivated` extension to the builder.
115+
* Add the `onlyNotActivated` extension to the builder.
116116
*
117117
* @param \Illuminate\Database\Eloquent\Builder $builder
118118
* @return void
119119
*/
120-
protected function addOnlyDeactivated(Builder $builder): void
120+
protected function addOnlyNotActivated(Builder $builder): void
121121
{
122-
$builder->macro('onlyDeactivated', function (Builder $builder) {
122+
$builder->macro('onlyNotActivated', function (Builder $builder) {
123123
return $builder->withoutGlobalScope($this)->where('is_active', 0);
124124
});
125125
}

0 commit comments

Comments
 (0)