-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding constants & scopes for Role Model * Fixing `User::isAdmin()` method * Refactoring and other stuff
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- 2.3.1
- 2.3.0
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.1
- 1.8.0
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- 0.19.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
1 parent
5b21d24
commit dd37c86
Showing
4 changed files
with
42 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,54 @@ | ||
<?php namespace Arcanesoft\Auth\Models; | ||
|
||
use Arcanedev\LaravelAuth\Models\Role as BaseRoleModel; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
/** | ||
* Class Role | ||
* | ||
* @package Arcanesoft\Auth\Models | ||
* @author ARCANEDEV <[email protected]> | ||
* | ||
* @method static \Illuminate\Database\Eloquent\Builder admins() | ||
* @method static \Illuminate\Database\Eloquent\Builder members() | ||
*/ | ||
class Role extends BaseRoleModel | ||
{ | ||
/* ------------------------------------------------------------------------------------------------ | ||
| Constants | ||
| ------------------------------------------------------------------------------------------------ | ||
*/ | ||
const ADMINISTRATOR = 'administrator'; | ||
const MEMBER = 'member'; | ||
|
||
/* ------------------------------------------------------------------------------------------------ | ||
| Scopes | ||
| ------------------------------------------------------------------------------------------------ | ||
*/ | ||
/** | ||
* Scope only admin roles. | ||
* | ||
* @param \Illuminate\Database\Eloquent\Builder $query | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder | ||
*/ | ||
public function scopeAdmins(Builder $query) | ||
{ | ||
return $query->where('slug', Role::ADMINISTRATOR); | ||
} | ||
|
||
/** | ||
* Scope only admin roles. | ||
* | ||
* @param \Illuminate\Database\Eloquent\Builder $query | ||
* | ||
* @return \Illuminate\Database\Eloquent\Builder | ||
*/ | ||
public function scopeMembers(Builder $query) | ||
{ | ||
return $query->where('slug', Role::MEMBER); | ||
} | ||
|
||
/* ------------------------------------------------------------------------------------------------ | ||
| Getters & Setters | ||
| ------------------------------------------------------------------------------------------------ | ||
|
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