File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 1010use Illuminate \Support \ServiceProvider ;
1111use Illuminate \Contracts \Auth \Access \Gate ;
1212use Illuminate \Database \Eloquent \Relations \Relation ;
13+ use Illuminate \Database \Eloquent \Model as EloquentModel ;
1314
1415class BouncerServiceProvider extends ServiceProvider
1516{
@@ -118,13 +119,15 @@ protected function publishMigrations()
118119 */
119120 protected function setUserModel ()
120121 {
121- Models::setUsersModel ($ this ->getUserModel ());
122+ if ($ model = $ this ->getUserModel ()) {
123+ Models::setUsersModel ($ model );
124+ }
122125 }
123126
124127 /**
125128 * Get the user model from the application's auth config.
126129 *
127- * @return string
130+ * @return string|null
128131 */
129132 protected function getUserModel ()
130133 {
@@ -138,7 +141,14 @@ protected function getUserModel()
138141 return null ;
139142 }
140143
141- return $ config ->get ("auth.providers. {$ provider }.model " );
144+ $ model = $ config ->get ("auth.providers. {$ provider }.model " );
145+
146+ // The standard auth config that ships with Laravel references the
147+ // Eloquent User model in the above config path. However, users
148+ // are free to reference anything there - so we check first.
149+ if (is_subclass_of ($ model , EloquentModel::class)) {
150+ return $ model ;
151+ }
142152 }
143153
144154 /**
You can’t perform that action at this time.
0 commit comments