Admin   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 60
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 27 1
A getRouteKeyName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Auth\Models;
6
7
use Cortex\Auth\Notifications\PhoneVerificationNotification;
8
use Cortex\Auth\Notifications\AdminPasswordResetNotification;
9
use Cortex\Auth\Notifications\AdminEmailVerificationNotification;
10
11
class Admin extends User
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    protected $passwordResetNotificationClass = AdminPasswordResetNotification::class;
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected $emailVerificationNotificationClass = AdminEmailVerificationNotification::class;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected $phoneVerificationNotificationClass = PhoneVerificationNotification::class;
27
28
    /**
29
     * Create a new Eloquent model instance.
30
     *
31
     * @param array $attributes
32
     */
33
    public function __construct(array $attributes = [])
34
    {
35
        parent::__construct($attributes);
36
37
        $this->setTable(config('cortex.auth.tables.admins'));
38
        $this->setRules([
39
            'username' => 'required|alpha_dash|min:3|max:150|unique:'.config('cortex.auth.tables.admins').',username',
40
            'password' => 'sometimes|required|min:'.config('cortex.auth.password_min_chars'),
41
            'two_factor' => 'nullable|array',
42
            'email' => 'required|email|min:3|max:150|unique:'.config('cortex.auth.tables.admins').',email',
43
            'email_verified_at' => 'nullable|date',
44
            'phone' => 'nullable|phone:AUTO',
45
            'phone_verified_at' => 'nullable|date',
46
            'given_name' => 'required|string|max:150',
47
            'family_name' => 'nullable|string|max:150',
48
            'title' => 'nullable|string|max:150',
49
            'organization' => 'nullable|string|max:150',
50
            'country_code' => 'nullable|alpha|size:2|country',
51
            'language_code' => 'nullable|alpha|size:2|language',
52
            'birthday' => 'nullable|date_format:Y-m-d',
53
            'gender' => 'nullable|in:male,female',
54
            'social' => 'nullable',
55
            'is_active' => 'sometimes|boolean',
56
            'last_activity' => 'nullable|date',
57
            'tags' => 'nullable|array',
58
        ]);
59
    }
60
61
    /**
62
     * Get the route key for the model.
63
     *
64
     * @return string
65
     */
66
    public function getRouteKeyName()
67
    {
68
        return 'username';
69
    }
70
}
71