This repository was archived by the owner on Apr 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-16
lines changed Expand file tree Collapse file tree 2 files changed +30
-16
lines changed Original file line number Diff line number Diff line change 77
88class TwoFactorAuth extends Model
99{
10+ /**
11+ * The reference to the user model.
12+ *
13+ * @var string
14+ */
15+ private $ model ;
16+
1017 /**
1118 * The attributes that are mass assignable.
1219 *
1320 * @var array
1421 */
1522 protected $ fillable = [
16- 'id ' , 'user_id '
23+ 'id ' , 'user_id ' ,
1724 ];
1825
1926 /**
@@ -22,7 +29,7 @@ class TwoFactorAuth extends Model
2229 * @var array
2330 */
2431 protected $ hidden = [
25- 'id '
32+ 'id ' ,
2633 ];
2734
2835 /**
@@ -39,10 +46,22 @@ class TwoFactorAuth extends Model
3946 */
4047 public function user () : BelongsTo
4148 {
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 ' , $ 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 ;
4766 }
4867}
Original file line number Diff line number Diff line change 8484
8585 /*
8686 |--------------------------------------------------------------------------
87- | Model Setttings
87+ | Model
8888 |--------------------------------------------------------------------------
8989 |
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.
9192 |
9293 */
9394
94- 'models ' => [
95-
96- 'user ' => [
97- 'primaryKey ' => 'id ' ,
98- ],
99-
100- ],
95+ 'model ' => \App \User::class,
10196
10297];
You can’t perform that action at this time.
0 commit comments