コード例 #1
0
 /**
  * Fills a models attributes by the specified Users attributes.
  *
  * @param User            $user
  * @param Authenticatable $model
  *
  * @return Authenticatable
  */
 protected function syncModelFromAdldap(User $user, Authenticatable $model)
 {
     $attributes = $this->getSyncAttributes();
     foreach ($attributes as $modelField => $adField) {
         $adValue = $user->{$adField};
         if (is_array($adValue)) {
             $adValue = Arr::get($adValue, 0);
         }
         $model->{$modelField} = $adValue;
     }
     // Only save models that contain changes
     if (count($model->getDirty()) > 0) {
         $model->save();
     }
     return $model;
 }