<commit_before><?php namespace Anomaly\UserFieldType;

use Anomaly\Streams\Platform\Addon\FieldType\FieldTypeModifier;
use Anomaly\Streams\Platform\Model\EloquentModel;

/**
 * Class UserFieldTypeModifier
 *
 * @link          http://anomaly.is/streams-platform
 * @author        AnomalyLabs, Inc. <<EMAIL>>
 * @author        <NAME> <<EMAIL>>
 * @package       Anomaly\UserFieldType
 */
class UserFieldTypeModifier extends FieldTypeModifier
{

    /**
     * The field type instance.
     * This is for IDE support.
     *
     * @var UserFieldType
     */
    protected $fieldType;

    /**
     * Restore the value.
     *
     * @param $value
     * @return null|EloquentModel
     */
    public function restore($value)
    {
        if (is_numeric($value)) {

            $relation = $this->fieldType->getRelatedModel();

            return $relation->find($value);
        }

        return $value;
    }
}<commit_msg>If an instance is set then return the ID for storage<commit_after><?php namespace Anomaly\UserFieldType;

use Anomaly\Streams\Platform\Addon\FieldType\FieldTypeModifier;
use Anomaly\Streams\Platform\Model\EloquentModel;
use Anomaly\UsersModule\User\Contract\UserInterface;

/**
 * Class UserFieldTypeModifier
 *
 * @link          http://anomaly.is/streams-platform
 * @author        AnomalyLabs, Inc. <<EMAIL>>
 * @author        <NAME> <<EMAIL>>
 * @package       Anomaly\UserFieldType
 */
class UserFieldTypeModifier extends FieldTypeModifier
{

    /**
     * The field type instance.
     * This is for IDE support.
     *
     * @var UserFieldType
     */
    protected $fieldType;

    /**
     * Modify the value.
     *
     * @param $value
     * @return int
     */
    public function modify($value)
    {
        if ($value instanceof UserInterface) {
            return $value->getId();
        }

        return $value;
    }

    /**
     * Restore the value.
     *
     * @param $value
     * @return null|EloquentModel
     */
    public function restore($value)
    {
        if (is_numeric($value)) {

            $relation = $this->fieldType->getRelatedModel();

            return $relation->find($value);
        }

        return $value;
    }
}
{'fraction_non_alphanumeric': 0.11958010041077134, 'fraction_numerical': 0.0, 'mean_word_length': 2.2330383480825957, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4202055', 'n_tokens_mistral': 676, 'n_tokens_neox': 656, 'n_words': 140}