Completed
Push — master ( d778e6...6d1c30 )
by ARCANEDEV
08:16
created

User::hasher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php namespace Arcanesoft\Auth\Models;
2
3
use Arcanedev\LaravelAuth\Models\User as BaseUserModel;
4
5
/**
6
 * Class     User
7
 *
8
 * @package  Arcanesoft\Auth\Models
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class User extends BaseUserModel
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: can, getAuthIdentifier, getAuthIdentifierName, getAuthPassword, getEmailForPasswordReset, getRememberToken, getRememberTokenName, sendPasswordResetNotification, setAttribute, setRememberToken
Loading history...
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Traits
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    use Presenters\UserPresenter;
18
19
    /* ------------------------------------------------------------------------------------------------
20
     |  Main Function
21
     | ------------------------------------------------------------------------------------------------
22
     */
23
    /**
24
     * Get a user from a hashed id or fail if not found.
25
     *
26
     * @param  string  $hashedId
27
     *
28
     * @return self
29
     *
30
     * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
31
     */
32
    public static function firstHashedOrFail($hashedId)
33
    {
34
        return self::withTrashed()->withHashedId($hashedId)->firstOrFail();
35
    }
36
37
    /* ------------------------------------------------------------------------------------------------
38
     |  Check Functions
39
     | ------------------------------------------------------------------------------------------------
40
     */
41
    /**
42
     * Check if user is an administrator.
43
     *
44
     * @return bool
45
     */
46
    public function isAdmin()
47
    {
48
        return parent::isAdmin() || $this->hasRoleSlug(Role::ADMINISTRATOR);
49
    }
50
51
    /**
52
     * Check if user is a moderator.
53
     *
54
     * @return bool
55
     */
56
    public function isModerator()
57
    {
58
        return $this->hasRoleSlug(Role::MODERATOR);
59
    }
60
61
    /**
62
     * Check if user is a member.
63
     *
64
     * @return bool
65
     */
66
    public function isMember()
67
    {
68
        return $this->hasRoleSlug(Role::MEMBER);
69
    }
70
}
71