public function getAttribute($key, $model = false)
    {
        if (!$key) {
            return;
        }

        if (!$model) {
            $model = $this->model;
        }

        $formattedKey = str_replace('.', '_', $key);

        if ($this->hasGetAccessor($formattedKey)) {
            $method = 'get'.Str::studly($formattedKey).'Attribute';

            return $this->{$method}($model);
        }

        if ($this->hasGetAccessor($key)) {
            $method = 'get'.Str::studly($key).'Attribute';

            return $this->{$method}($model);
        }

        if ($this->hasRelatedKey($key, $model)) {
            return $this->relatedKey($key, $model);
        }

        return $model->getAttribute($key);
    }