Skip to content

Commit e5bf600

Browse files
committed
Follow approved naming convention
1 parent 007ab71 commit e5bf600

File tree

9 files changed

+107
-82
lines changed

9 files changed

+107
-82
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ All notable changes to `laravel-eloquent-flag` will be documented in this file.
1212

1313
### Changed
1414

15-
- Each Flag trait was spliced on 2 additional traits: `Has{Name}Flag` = `Has{Name}FlagScope` + `Has{Name}FlagHelpers`
15+
- Each Flag trait was spliced on 2 additional traits: `Has{Name}Flag` = `Has{Name}FlagScope` + `Has{Name}FlagHelpers`.
1616
- Kept Flag trait was spliced on 3 additional traits, because events were pulled out to `HasKeptFlagBehavior` trait.
17+
- Flags `Classic\Accepted`, `Classic\Active` & `Classic\Approved` methods were changed. Details in the [UPGRADING.md](UPGRADING.md).
1718

1819
## 2.1.0 - 2016-01-04
1920

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ class Post extends Model
8484

8585
```php
8686
Post::all();
87-
Post::withoutInactive();
87+
Post::withoutDeactivated();
8888
```
8989

90-
#### Get only inactive models
90+
#### Get only deactivated models
9191

9292
```php
93-
Post::onlyInactive();
93+
Post::onlyDeactivated();
9494
```
9595

96-
#### Get active + inactive models
96+
#### Get active + deactivated models
9797

9898
```php
99-
Post::withInactive();
99+
Post::withDeactivated();
100100
```
101101

102102
#### Activate model
@@ -135,19 +135,19 @@ class Post extends Model
135135

136136
```php
137137
Post::all();
138-
Post::withoutUnaccepted();
138+
Post::withoutRejected();
139139
```
140140

141-
#### Get only unaccepted models
141+
#### Get only rejected models
142142

143143
```php
144-
Post::onlyUnaccepted();
144+
Post::onlyRejected();
145145
```
146146

147-
#### Get accepted + unaccepted models
147+
#### Get accepted + rejected models
148148

149149
```php
150-
Post::withUnaccepted();
150+
Post::withRejected();
151151
```
152152

153153
#### Accept model
@@ -159,7 +159,7 @@ Post::where('id', 4)->accept();
159159
#### Deactivate model
160160

161161
```php
162-
Post::where('id', 4)->unaccept();
162+
Post::where('id', 4)->reject();
163163
```
164164

165165
### Setup an approvable model
@@ -186,19 +186,19 @@ class Post extends Model
186186

187187
```php
188188
Post::all();
189-
Post::withoutUnapproved();
189+
Post::withoutDisapproved();
190190
```
191191

192-
#### Get only unapproved models
192+
#### Get only disapproved models
193193

194194
```php
195-
Post::onlyUnapproved();
195+
Post::onlyDisapproved();
196196
```
197197

198-
#### Get approved + unapproved models
198+
#### Get approved + disapproved models
199199

200200
```php
201-
Post::withUnapproved();
201+
Post::withDisapproved();
202202
```
203203

204204
#### Approve model
@@ -207,10 +207,10 @@ Post::withUnapproved();
207207
Post::where('id', 4)->approve();
208208
```
209209

210-
#### Unapprove model
210+
#### Disapprove model
211211

212212
```php
213-
Post::where('id', 4)->unapprove();
213+
Post::where('id', 4)->disapprove();
214214
```
215215

216216
### Setup a publishable model

UPGRADING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Upgrading
2+
3+
## From v2 to v3
4+
5+
You can upgrade from v2 to v3 by performing these renames in your model that has flags: `Accepted`, `Active` & `Approved`.
6+
7+
These methods should be renamed:
8+
9+
- `unaccept()` has been renamed to `reject()`.
10+
- `withUnaccepted()` has been renamed to `withRejected()`.
11+
- `withoutUnaccepted()` has been renamed to `withoutRejected()`.
12+
- `onlyUnaccepted()` has been renamed to `onlyRejected()`.
13+
- `withInactive()` has been renamed to `withDeactivated()`.
14+
- `withoutInactive()` has been renamed to `withoutDeactivated()`.
15+
- `onlyInactive()` has been renamed to `onlyDeactivated()`.
16+
- `unapprove()` has been renamed to `disapprove()`.
17+
- `withUnapproved()` has been renamed to `withDisapproved()`.
18+
- `withoutUnapproved()` has been renamed to `withoutDisapproved()`.
19+
- `onlyUnapproved()` has been renamed to `onlyDisapproved()`.
20+
21+
## From v1 to v2
22+
23+
- Namespaces of flag's traits received `Classic` at the end: `Cog\Flag\Traits\Classic`.
24+
- Namespaces of flag's scopes received `Classic` at the end: `Cog\Flag\Scopes\Classic`.

src/Scopes/Classic/AcceptedFlagScope.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AcceptedFlagScope implements Scope
2727
*
2828
* @var array
2929
*/
30-
protected $extensions = ['Accept', 'Unaccept', 'WithUnaccepted', 'WithoutUnaccepted', 'OnlyUnaccepted'];
30+
protected $extensions = ['Accept', 'Reject', 'WithRejected', 'WithoutRejected', 'OnlyRejected'];
3131

3232
/**
3333
* Apply the scope to a given Eloquent query builder.
@@ -63,60 +63,60 @@ public function extend(Builder $builder)
6363
protected function addAccept(Builder $builder)
6464
{
6565
$builder->macro('accept', function (Builder $builder) {
66-
$builder->withUnaccepted();
66+
$builder->withRejected();
6767

6868
return $builder->update(['is_accepted' => 1]);
6969
});
7070
}
7171

7272
/**
73-
* Add the `unaccept` extension to the builder.
73+
* Add the `reject` extension to the builder.
7474
*
7575
* @param \Illuminate\Database\Eloquent\Builder $builder
7676
* @return void
7777
*/
78-
protected function addUnaccept(Builder $builder)
78+
protected function addReject(Builder $builder)
7979
{
80-
$builder->macro('unaccept', function (Builder $builder) {
80+
$builder->macro('reject', function (Builder $builder) {
8181
return $builder->update(['is_accepted' => 0]);
8282
});
8383
}
8484

8585
/**
86-
* Add the `withUnaccepted` extension to the builder.
86+
* Add the `withRejected` extension to the builder.
8787
*
8888
* @param \Illuminate\Database\Eloquent\Builder $builder
8989
* @return void
9090
*/
91-
protected function addWithUnaccepted(Builder $builder)
91+
protected function addWithRejected(Builder $builder)
9292
{
93-
$builder->macro('withUnaccepted', function (Builder $builder) {
93+
$builder->macro('withRejected', function (Builder $builder) {
9494
return $builder->withoutGlobalScope($this);
9595
});
9696
}
9797

9898
/**
99-
* Add the `withoutUnaccepted` extension to the builder.
99+
* Add the `withoutRejected` extension to the builder.
100100
*
101101
* @param \Illuminate\Database\Eloquent\Builder $builder
102102
* @return void
103103
*/
104-
protected function addWithoutUnaccepted(Builder $builder)
104+
protected function addWithoutRejected(Builder $builder)
105105
{
106-
$builder->macro('withoutUnaccepted', function (Builder $builder) {
106+
$builder->macro('withoutRejected', function (Builder $builder) {
107107
return $builder->withoutGlobalScope($this)->where('is_accepted', 1);
108108
});
109109
}
110110

111111
/**
112-
* Add the `onlyUnaccepted` extension to the builder.
112+
* Add the `onlyRejected` extension to the builder.
113113
*
114114
* @param \Illuminate\Database\Eloquent\Builder $builder
115115
* @return void
116116
*/
117-
protected function addOnlyUnaccepted(Builder $builder)
117+
protected function addOnlyRejected(Builder $builder)
118118
{
119-
$builder->macro('onlyUnaccepted', function (Builder $builder) {
119+
$builder->macro('onlyRejected', function (Builder $builder) {
120120
return $builder->withoutGlobalScope($this)->where('is_accepted', 0);
121121
});
122122
}

src/Scopes/Classic/ActiveFlagScope.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ActiveFlagScope implements Scope
2727
*
2828
* @var array
2929
*/
30-
protected $extensions = ['Activate', 'Deactivate', 'WithInactive', 'WithoutInactive', 'OnlyInactive'];
30+
protected $extensions = ['Activate', 'Deactivate', 'WithDeactivated', 'WithoutDeactivated', 'OnlyDeactivated'];
3131

3232
/**
3333
* Apply the scope to a given Eloquent query builder.
@@ -63,7 +63,7 @@ public function extend(Builder $builder)
6363
protected function addActivate(Builder $builder)
6464
{
6565
$builder->macro('activate', function (Builder $builder) {
66-
$builder->withInactive();
66+
$builder->withDeactivated();
6767

6868
return $builder->update(['is_active' => 1]);
6969
});
@@ -83,40 +83,40 @@ protected function addDeactivate(Builder $builder)
8383
}
8484

8585
/**
86-
* Add the `withInactive` extension to the builder.
86+
* Add the `withDeactivated` extension to the builder.
8787
*
8888
* @param \Illuminate\Database\Eloquent\Builder $builder
8989
* @return void
9090
*/
91-
protected function addWithInactive(Builder $builder)
91+
protected function addWithDeactivated(Builder $builder)
9292
{
93-
$builder->macro('withInactive', function (Builder $builder) {
93+
$builder->macro('withDeactivated', function (Builder $builder) {
9494
return $builder->withoutGlobalScope($this);
9595
});
9696
}
9797

9898
/**
99-
* Add the `withoutInactive` extension to the builder.
99+
* Add the `withoutDeactivated` extension to the builder.
100100
*
101101
* @param \Illuminate\Database\Eloquent\Builder $builder
102102
* @return void
103103
*/
104-
protected function addWithoutInactive(Builder $builder)
104+
protected function addWithoutDeactivated(Builder $builder)
105105
{
106-
$builder->macro('withoutInactive', function (Builder $builder) {
106+
$builder->macro('withoutDeactivated', function (Builder $builder) {
107107
return $builder->withoutGlobalScope($this)->where('is_active', 1);
108108
});
109109
}
110110

111111
/**
112-
* Add the `onlyInactive` extension to the builder.
112+
* Add the `onlyDeactivated` extension to the builder.
113113
*
114114
* @param \Illuminate\Database\Eloquent\Builder $builder
115115
* @return void
116116
*/
117-
protected function addOnlyInactive(Builder $builder)
117+
protected function addOnlyDeactivated(Builder $builder)
118118
{
119-
$builder->macro('onlyInactive', function (Builder $builder) {
119+
$builder->macro('onlyDeactivated', function (Builder $builder) {
120120
return $builder->withoutGlobalScope($this)->where('is_active', 0);
121121
});
122122
}

src/Scopes/Classic/ApprovedFlagScope.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ApprovedFlagScope implements Scope
2727
*
2828
* @var array
2929
*/
30-
protected $extensions = ['Approve', 'Unapprove', 'WithUnapproved', 'WithoutUnapproved', 'OnlyUnapproved'];
30+
protected $extensions = ['Approve', 'Disapprove', 'WithDisapproved', 'WithoutDisapproved', 'OnlyDisapproved'];
3131

3232
/**
3333
* Apply the scope to a given Eloquent query builder.
@@ -63,60 +63,60 @@ public function extend(Builder $builder)
6363
protected function addApprove(Builder $builder)
6464
{
6565
$builder->macro('approve', function (Builder $builder) {
66-
$builder->withUnapproved();
66+
$builder->withDisapproved();
6767

6868
return $builder->update(['is_approved' => 1]);
6969
});
7070
}
7171

7272
/**
73-
* Add the `unapprove` extension to the builder.
73+
* Add the `disapprove` extension to the builder.
7474
*
7575
* @param \Illuminate\Database\Eloquent\Builder $builder
7676
* @return void
7777
*/
78-
protected function addUnapprove(Builder $builder)
78+
protected function addDisapprove(Builder $builder)
7979
{
80-
$builder->macro('unapprove', function (Builder $builder) {
80+
$builder->macro('disapprove', function (Builder $builder) {
8181
return $builder->update(['is_approved' => 0]);
8282
});
8383
}
8484

8585
/**
86-
* Add the `withUnapproved` extension to the builder.
86+
* Add the `withDisapproved` extension to the builder.
8787
*
8888
* @param \Illuminate\Database\Eloquent\Builder $builder
8989
* @return void
9090
*/
91-
protected function addWithUnapproved(Builder $builder)
91+
protected function addWithDisapproved(Builder $builder)
9292
{
93-
$builder->macro('withUnapproved', function (Builder $builder) {
93+
$builder->macro('withDisapproved', function (Builder $builder) {
9494
return $builder->withoutGlobalScope($this);
9595
});
9696
}
9797

9898
/**
99-
* Add the `withoutUnapproved` extension to the builder.
99+
* Add the `withoutDisapproved` extension to the builder.
100100
*
101101
* @param \Illuminate\Database\Eloquent\Builder $builder
102102
* @return void
103103
*/
104-
protected function addWithoutUnapproved(Builder $builder)
104+
protected function addWithoutDisapproved(Builder $builder)
105105
{
106-
$builder->macro('withoutUnapproved', function (Builder $builder) {
106+
$builder->macro('withoutDisapproved', function (Builder $builder) {
107107
return $builder->withoutGlobalScope($this)->where('is_approved', 1);
108108
});
109109
}
110110

111111
/**
112-
* Add the `onlyUnapproved` extension to the builder.
112+
* Add the `onlyDisapproved` extension to the builder.
113113
*
114114
* @param \Illuminate\Database\Eloquent\Builder $builder
115115
* @return void
116116
*/
117-
protected function addOnlyUnapproved(Builder $builder)
117+
protected function addOnlyDisapproved(Builder $builder)
118118
{
119-
$builder->macro('onlyUnapproved', function (Builder $builder) {
119+
$builder->macro('onlyDisapproved', function (Builder $builder) {
120120
return $builder->withoutGlobalScope($this)->where('is_approved', 0);
121121
});
122122
}

0 commit comments

Comments
 (0)