public function setPreferencesAttribute($preferences)
    {
        if (is_array($preferences)) {
            $preferences = json_encode($preferences);
        }

        $this->attributes['preferences'] = $preferences;
    }