This repository was archived by the owner on Apr 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +31
-17
lines changed Expand file tree Collapse file tree 3 files changed +31
-17
lines changed Original file line number Diff line number Diff line change 7
7
"type" : " package" ,
8
8
"minimum-stability" : " dev" ,
9
9
"require" : {
10
- "illuminate/support" : " 5.5.*|5.6.*|5.7.*|5.8.*|^6.0 "
10
+ "illuminate/support" : " 5.5.*|5.6.*|5.7.*|5.8.*|6.* "
11
11
},
12
12
"extra" : {
13
13
"laravel" : {
Original file line number Diff line number Diff line change 7
7
8
8
class TwoFactorAuth extends Model
9
9
{
10
+ /**
11
+ * The reference to the user model.
12
+ *
13
+ * @var string
14
+ */
15
+ private $ model ;
16
+
10
17
/**
11
18
* The attributes that are mass assignable.
12
19
*
13
20
* @var array
14
21
*/
15
22
protected $ fillable = [
16
- 'id ' , 'user_id '
23
+ 'id ' , 'user_id ' ,
17
24
];
18
25
19
26
/**
@@ -22,7 +29,7 @@ class TwoFactorAuth extends Model
22
29
* @var array
23
30
*/
24
31
protected $ hidden = [
25
- 'id '
32
+ 'id ' ,
26
33
];
27
34
28
35
/**
@@ -39,10 +46,22 @@ class TwoFactorAuth extends Model
39
46
*/
40
47
public function user () : BelongsTo
41
48
{
42
- return $ this ->belongsTo (
43
- \App \User::class,
44
- 'user_id ' ,
45
- config ('twofactor-auth.models.user.primaryKey ' , 'id ' )
46
- );
49
+ $ model = $ this ->model ();
50
+
51
+ return $ this ->belongsTo ($ model , 'user_id ' , (new $ model )->getKeyName ());
52
+ }
53
+
54
+ /**
55
+ * Get the reference to the user model.
56
+ *
57
+ * @return string
58
+ */
59
+ private function model () : string
60
+ {
61
+ if (is_null ($ this ->model )) {
62
+ $ this ->model = config ('twofactor-auth.model ' );
63
+ }
64
+
65
+ return $ this ->model ;
47
66
}
48
67
}
Original file line number Diff line number Diff line change 84
84
85
85
/*
86
86
|--------------------------------------------------------------------------
87
- | Model Setttings
87
+ | Model
88
88
|--------------------------------------------------------------------------
89
89
|
90
- | Here you can specify some custom properties of the default user model.
90
+ | Here you can optionally specify the user model that should be used. The
91
+ | standard "Eloquent" user model is configured by default.
91
92
|
92
93
*/
93
94
94
- 'models ' => [
95
-
96
- 'user ' => [
97
- 'primaryKey ' => 'id ' ,
98
- ],
99
-
100
- ],
95
+ 'model ' => \App \User::class,
101
96
102
97
];
You can’t perform that action at this time.
0 commit comments