Completed
Push — develop ( 10b573...34b970 )
by Abdelrahman
09:38
created

User::causedActivity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Fort\Models;
6
7
use Rinvex\Tenants\Traits\Tenantable;
8
use Cortex\Foundation\Traits\Auditable;
9
use Rinvex\Cacheable\CacheableEloquent;
10
use Rinvex\Fort\Models\User as BaseUser;
11
use Rinvex\Attributes\Traits\Attributable;
12
use Spatie\MediaLibrary\HasMedia\HasMedia;
13
use Spatie\Activitylog\Traits\HasActivity;
14
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
15
use Cortex\Fort\Notifications\PasswordResetNotification;
16
use Cortex\Fort\Notifications\EmailVerificationNotification;
17
use Cortex\Fort\Notifications\PhoneVerificationNotification;
18
19
/**
20
 * Cortex\Fort\Models\User.
21
 *
22
 * @property int                                                                                                            $id
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
23
 * @property string                                                                                                         $username
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
24
 * @property string                                                                                                         $password
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
25
 * @property string|null                                                                                                    $remember_token
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
26
 * @property string                                                                                                         $email
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 130 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
27
 * @property bool                                                                                                           $email_verified
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
28
 * @property \Carbon\Carbon                                                                                                 $email_verified_at
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 142 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
29
 * @property string                                                                                                         $phone
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 130 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
30
 * @property bool                                                                                                           $phone_verified
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
31
 * @property \Carbon\Carbon                                                                                                 $phone_verified_at
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 142 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
32
 * @property string                                                                                                         $name_prefix
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 136 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
33
 * @property string                                                                                                         $first_name
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
34
 * @property string                                                                                                         $middle_name
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 136 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
35
 * @property string                                                                                                         $last_name
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 134 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
36
 * @property string                                                                                                         $name_suffix
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 136 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
37
 * @property string                                                                                                         $title
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 130 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
38
 * @property string                                                                                                         $country_code
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 137 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
39
 * @property string                                                                                                         $language_code
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
40
 * @property array                                                                                                          $two_factor
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
41
 * @property string                                                                                                         $birthday
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
42
 * @property string                                                                                                         $gender
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 131 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
43
 * @property bool                                                                                                           $is_active
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 134 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
44
 * @property \Carbon\Carbon                                                                                                 $last_activity
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
45
 * @property \Carbon\Carbon|null                                                                                            $created_at
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
46
 * @property \Carbon\Carbon|null                                                                                            $updated_at
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
47
 * @property \Carbon\Carbon|null                                                                                            $deleted_at
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
48
 * @property \Illuminate\Database\Eloquent\Collection|\Cortex\Fort\Models\Ability[]                                         $abilities
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 134 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
49
 * @property-read \Illuminate\Database\Eloquent\Collection|\Cortex\Foundation\Models\Log[]                                  $activity
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
50
 * @property-read \Illuminate\Database\Eloquent\Collection|\Cortex\Foundation\Models\Log[]                                  $actions
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 132 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
51
 * @property-read \Illuminate\Support\Collection                                                                            $all_abilities
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
52
 * @property-read \Rinvex\Country\Country                                                                                   $country
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 132 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
53
 * @property mixed                                                                                                          $entity
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 131 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
54
 * @property-read \Rinvex\Language\Language                                                                                 $language
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
55
 * @property-read string                                                                                                    $name
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 129 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
56
 * @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
57
 * @property \Illuminate\Database\Eloquent\Collection|\Cortex\Fort\Models\Role[]                                            $roles
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 130 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
58
 * @property-read \Illuminate\Database\Eloquent\Collection|\Rinvex\Fort\Models\Session[]                                    $sessions
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
59
 * @property \Illuminate\Database\Eloquent\Collection|\Cortex\Tenants\Models\Tenant[]                                       $tenants
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 132 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
60
 * @property-read \Illuminate\Database\Eloquent\Collection|\Rinvex\Fort\Models\Socialite[]                                  $socialites
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 135 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
61
 *
62
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User hasAttribute($key, $value)
63
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User role($roles)
64
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereBirthday($value)
65
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereCountryCode($value)
66
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereCreatedAt($value)
67
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereDeletedAt($value)
68
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereEmail($value)
69
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereEmailVerified($value)
70
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereEmailVerifiedAt($value)
71
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereFirstName($value)
72
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereGender($value)
73
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereId($value)
74
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereIsActive($value)
75
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereLanguageCode($value)
76
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereLastActivity($value)
77
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereLastName($value)
78
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereMiddleName($value)
79
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereNamePrefix($value)
80
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereNameSuffix($value)
81
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User wherePassword($value)
82
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User wherePhone($value)
83
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User wherePhoneVerified($value)
84
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User wherePhoneVerifiedAt($value)
85
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereRememberToken($value)
86
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereTitle($value)
87
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereTwoFactor($value)
88
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereUpdatedAt($value)
89
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User whereUsername($value)
90
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User withAllTenants($tenants, $group = null)
91
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User withAnyTenants($tenants, $group = null)
92
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User withTenants($tenants, $group = null)
93
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User withoutAnyTenants()
94
 * @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Fort\Models\User withoutTenants($tenants, $group = null)
95
 * @mixin \Eloquent
96
 */
97
class User extends BaseUser implements HasMedia
98
{
99
    // @TODO: Strangely, this issue happens only here!!!
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
100
    // Duplicate trait usage to fire attached events for cache
101
    // flush before other events in other traits specially LogsActivity,
102
    // otherwise old cached queries used and no changelog recorded on update.
103
    use CacheableEloquent;
104
    use Auditable;
105
    use Tenantable;
106
    use HasActivity;
107
    use Attributable;
108
    use HasMediaTrait;
109
110
    /**
111
     * Indicates whether to log only dirty attributes or all.
112
     *
113
     * @var bool
114
     */
115
    protected static $logOnlyDirty = true;
116
117
    /**
118
     * The attributes that are logged on change.
119
     *
120
     * @var array
121
     */
122
    protected static $logAttributes = [
123
        'username',
124
        'email',
125
        'email_verified',
126
        'phone',
127
        'phone_verified',
128
        'name_prefix',
129
        'first_name',
130
        'middle_name',
131
        'last_name',
132
        'name_suffix',
133
        'title',
134
        'country_code',
135
        'language_code',
136
        'birthday',
137
        'gender',
138
        'is_active',
139
        'abilities',
140
        'roles',
141
    ];
142
143
    /**
144
     * The attributes that are ignored on change.
145
     *
146
     * @var array
147
     */
148
    protected static $ignoreChangedAttributes = [
149
        'password',
150
        'two_factor',
151
        'email_verified_at',
152
        'phone_verified_at',
153
        'last_activity',
154
        'created_at',
155
        'updated_at',
156
        'deleted_at',
157
    ];
158
159
    /**
160
     * {@inheritdoc}
161
     */
162
    protected $passwordResetNotificationClass = PasswordResetNotification::class;
163
164
    /**
165
     * {@inheritdoc}
166
     */
167
    protected $emailVerificationNotificationClass = EmailVerificationNotification::class;
168
169
    /**
170
     * {@inheritdoc}
171
     */
172
    protected $phoneVerificationNotificationClass = PhoneVerificationNotification::class;
173
174
    /**
175
     * Get the route key for the model.
176
     *
177
     * @return string
178
     */
179
    public function getRouteKeyName(): string
180
    {
181
        return 'username';
182
    }
183
184
    /**
185
     * Register media collections.
186
     *
187
     * @return void
188
     */
189
    public function registerMediaCollections(): void
190
    {
191
        $this->addMediaCollection('profile_picture')->singleFile();
192
        $this->addMediaCollection('cover_photo')->singleFile();
193
    }
194
}
195