code: protected function modelKeyForField($field, $model)
      {
          if (isset($this->attributes[$field])) {
              return $this->attributes[$field];
          }
  
          $key = $model::$snakeAttributes ? Str::underscore($field) : Str::camelize($field);
  
          return $this->attributes[$field] = $key;
      }
docs: Convert a JSON API resource field name to a model key.
  
  @param $field
  @param Model $model
  @return string