@@ -43,9 +43,7 @@ protected function getModelFromAdldap(User $user, $password)
4343 $ model = $ this ->createModel ()->newQuery ()->where ([$ key => $ username ])->first ();
4444
4545 // Create the model instance of it isn't found.
46- if (!$ model instanceof Model) {
47- $ model = $ this ->createModel ();
48- }
46+ $ model = ($ model instanceof Model ? $ model : $ this ->createModel ());
4947
5048 // Set the username and password in case
5149 // of changes in active directory.
@@ -58,9 +56,8 @@ protected function getModelFromAdldap(User $user, $password)
5856 // attributes on the model.
5957 $ model = $ this ->syncModelFromAdldap ($ user , $ model );
6058
61- if ($ this ->getBindUserToModel ()) {
62- $ model = $ this ->bindAdldapToModel ($ user , $ model );
63- }
59+ // Bind the Adldap model to the elqoquent model if configured.
60+ $ model = ($ this ->getBindUserToModel () ? $ this ->bindAdldapToModel ($ user , $ model ) : $ model );
6461
6562 return $ model ;
6663 }
@@ -185,11 +182,9 @@ protected function handleAttributeRetrieval(User $user, $field)
185182 } else {
186183 $ value = $ user ->{$ field };
187184
188- if (is_array ($ value )) {
189- // If the AD Value is an array, we'll
190- // retrieve the first value.
191- $ value = Arr::get ($ value , 0 );
192- }
185+ // If the AD Value is an array, we'll
186+ // retrieve the first value.
187+ $ value = (is_array ($ value ) ? Arr::get ($ value , 0 ) : $ value );
193188 }
194189
195190 return $ value ;
@@ -236,9 +231,7 @@ protected function getAdldap($provider = null)
236231 {
237232 $ ad = Adldap::getFacadeRoot ();
238233
239- if (is_null ($ provider )) {
240- $ provider = $ this ->getDefaultConnectionName ();
241- }
234+ $ provider = (is_null ($ provider ) ? $ this ->getDefaultConnectionName () : $ provider );
242235
243236 return $ ad ->getManager ()->get ($ provider );
244237 }
0 commit comments