<commit_before><?php namespace Laracasts\TestDummy;


use Illuminate\Database\Eloquent\Model as Eloquent;

class EloquentDatabaseProvider implements BuildableRepositoryInterface {

    /**
     * Create a new EloquentDatabase Provider instance.
     */
    function __construct()
    {
        // We can disable mass assignment protection.
        Eloquent::unguard();
    }

    /**
     * Build the entity with attributes.
     *
     * @param string $type
     * @param array $attributes
     * @throws TestDummyException
     * @return Eloquent
     */
    public function build($type, array $attributes)
    {
        if ( ! class_exists($type))
        {
            throw new TestDummyException("The {$type} model was not found.");
        }

        return new $type($attributes);
    }

    /**
     * Persist the entity.
     *
     * @param Model $entity
     * @return void
     */
    public function save($entity)
    {
        $entity->save();
    }

}<commit_msg>Mass assignment should be re-enabled after record creation with Eloquent driver.<commit_after><?php namespace Laracasts\TestDummy;


use Illuminate\Database\Eloquent\Model as Eloquent;

class EloquentDatabaseProvider implements BuildableRepositoryInterface {

    /**
     * Create a new EloquentDatabase Provider instance.
     */
    function __construct()
    {
        // We can disable mass assignment protection.
        Eloquent::unguard();
    }

    /**
     * Build the entity with attributes.
     *
     * @param string $type
     * @param array $attributes
     * @throws TestDummyException
     * @return Eloquent
     */
    public function build($type, array $attributes)
    {
        if ( ! class_exists($type))
        {
            throw new TestDummyException("The {$type} model was not found.");
        }

        $object = new $type($attributes);

        // Re-enable mass assignment protection
        Eloquent::reguard();

        return $object;
    }

    /**
     * Persist the entity.
     *
     * @param Model $entity
     * @return void
     */
    public function save($entity)
    {
        $entity->save();

        // Re-enable mass assignment protection
        Eloquent::reguard();
    }

}
{'fraction_non_alphanumeric': 0.10321412403802625, 'fraction_numerical': 0.0, 'mean_word_length': 2.152639087018545, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5521868', 'n_tokens_mistral': 627, 'n_tokens_neox': 607, 'n_words': 164}