Completed
Push — develop ( 1e6c4d...2ee822 )
by Abdelrahman
02:34
created

Member::getRouteKeyName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Auth\Models;
6
7
use Rinvex\Tenants\Traits\Tenantable;
8
use Cortex\Auth\Notifications\PhoneVerificationNotification;
9
use Cortex\Auth\Notifications\MemberPasswordResetNotification;
10
use Cortex\Auth\Notifications\MemberEmailVerificationNotification;
11
12
class Member extends User
13
{
14
    use Tenantable;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected $passwordResetNotificationClass = MemberPasswordResetNotification::class;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $passwordResetNotificationClass exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    protected $emailVerificationNotificationClass = MemberEmailVerificationNotification::class;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $emailVerificationNotificationClass exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected $phoneVerificationNotificationClass = PhoneVerificationNotification::class;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $phoneVerificationNotificationClass exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
30
31
    /**
32
     * Create a new Eloquent model instance.
33
     *
34
     * @param array $attributes
35
     */
36
    public function __construct(array $attributes = [])
37
    {
38
        parent::__construct($attributes);
39
40
        $this->setTable(config('cortex.auth.tables.members'));
41
        $this->setRules([
42
            'username' => 'required|alpha_dash|min:3|max:150|unique:'.config('cortex.auth.tables.members').',username',
43
            'password' => 'sometimes|required|min:'.config('cortex.auth.password_min_chars'),
44
            'two_factor' => 'nullable|array',
45
            'email' => 'required|email|min:3|max:150|unique:'.config('cortex.auth.tables.members').',email',
46
            'email_verified' => 'sometimes|boolean',
47
            'email_verified_at' => 'nullable|date',
48
            'phone' => 'nullable|phone:AUTO',
49
            'phone_verified' => 'sometimes|boolean',
50
            'phone_verified_at' => 'nullable|date',
51
            'full_name' => 'required|string|max:150',
52
            'title' => 'nullable|string|max:150',
53
            'country_code' => 'nullable|alpha|size:2|country',
54
            'language_code' => 'nullable|alpha|size:2|language',
55
            'birthday' => 'nullable|date_format:Y-m-d',
56
            'gender' => 'nullable|in:male,female',
57
            'is_active' => 'sometimes|boolean',
58
            'last_activity' => 'nullable|date',
59
            'tags' => 'nullable|array',
60
        ]);
61
    }
62
63
    /**
64
     * Get the route key for the model.
65
     *
66
     * @return string
67
     */
68
    public function getRouteKeyName()
69
    {
70
        return 'username';
71
    }
72
}
73