-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from hootlex/instance-methods
Instance methods
- Loading branch information
Showing
5 changed files
with
207 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Hootlex\Moderation; | ||
|
||
|
||
|
||
trait ModerationQueryBuilder | ||
{ | ||
/** | ||
* Get a new query builder that only includes pending resources. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder|static | ||
*/ | ||
public static function pending() | ||
{ | ||
return (new static)->newQueryWithoutScope(new ModerationScope())->pending(); | ||
} | ||
|
||
/** | ||
* Get a new query builder that only includes rejected resources. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder|static | ||
*/ | ||
public static function rejected() | ||
{ | ||
return (new static)->newQueryWithoutScope(new ModerationScope())->rejected(); | ||
} | ||
|
||
/** | ||
* Get a new query builder that only includes postponed resources. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder|static | ||
*/ | ||
public static function postponed() | ||
{ | ||
return (new static)->newQueryWithoutScope(new ModerationScope())->postponed(); | ||
} | ||
|
||
/** | ||
* Get a new query builder that includes pending resources. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder|static | ||
*/ | ||
public static function withPending() | ||
{ | ||
return (new static)->newQueryWithoutScope(new ModerationScope())->withPending(); | ||
} | ||
|
||
/** | ||
* Get a new query builder that includes rejected resources. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder|static | ||
*/ | ||
public static function withRejected() | ||
{ | ||
return (new static)->newQueryWithoutScope(new ModerationScope())->withRejected(); | ||
} | ||
|
||
/** | ||
* Get a new query builder that includes postponed resources. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder|static | ||
*/ | ||
public static function withPostponed() | ||
{ | ||
return (new static)->newQueryWithoutScope(new ModerationScope())->withPostponed(); | ||
} | ||
|
||
/** | ||
* Get a new query builder that includes all resources. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder|static | ||
*/ | ||
public static function withAnyStatus() | ||
{ | ||
return (new static)->newQueryWithoutScope(new ModerationScope()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters