src/BaseRepositoryEloquent.php
public function create(array $attributes)
    {
        /*
         * Check if is single associate array item.
         */
        if (array_is_assoc(head($attributes))) {
            throw new InvalidArgumentException('Trying to pass multiple items in create() method. Please use createMany() instead.');
        }

        // Unset primary key when $updateWhenIdExists is true, to make sure to create new record in database.
        if (array_is_assoc($attributes) && $this->updateWhenIdExists && array_key_exists($pk = $this->model->getKeyName(), $attributes)) {
            unset($attributes[$pk]);
        }

        $this->validation()->validate('create', $attributes);

        $model = $this->model->newInstance($attributes);

        $this->beforeSaveModel($model);

        $model->save();

        return $model;
    }
public function create(array $attributes)
    {
        /*
         * Check if is single associate array item.
         */
        if (array_is_assoc(head($attributes))) {
            throw new InvalidArgumentException('Trying to pass multiple items in create() method. Please use createMany() instead.');
        }

        // Unset primary key when $updateWhenIdExists is true, to make sure to create new record in database.
        if (array_is_assoc($attributes) && $this->updateWhenIdExists && array_key_exists($pk = $this->model->getKeyName(), $attributes)) {
            unset($attributes[$pk]);
        }

        $this->validation()->validate('create', $attributes);

        $model = $this->model->newInstance($attributes);

        $this->beforeSaveModel($model);

        $model->save();

        return $model;
    }
public function create ( array $ attributes ) { /*
         * Check if is single associate array item.
         */ if ( array_is_assoc ( head ( $ attributes ) ) ) { throw new InvalidArgumentException ( 'Trying to pass multiple items in create() method. Please use createMany() instead.' ) ; } // Unset primary key when $updateWhenIdExists is true, to make sure to create new record in database. if ( array_is_assoc ( $ attributes ) && $ this -> updateWhenIdExists && array_key_exists ( $ pk = $ this -> model -> getKeyName ( ) , $ attributes ) ) { unset ( $ attributes [ $ pk ] ) ; } $ this -> validation ( ) -> validate ( 'create' , $ attributes ) ; $ model = $ this -> model -> newInstance ( $ attributes ) ; $ this -> beforeSaveModel ( $ model ) ; $ model -> save ( ) ; return $ model ; }
Create and store a new model.

@param  array  $attributes
@return \Illuminate\Database\Eloquent\Model
Create and store a new model .