ardent icon indicating copy to clipboard operation
ardent copied to clipboard

Conflict between Eloquent save() and Ardent::save()

Open james-coder opened this issue 8 years ago • 0 comments

Similar to https://github.com/laravel-ardent/ardent/issues/296 I am experiencing problems with Ardent's save function.

It works for me when I do this, but surely there is a better way: (Maybe call Arduent's save something else?)

src/Ardent/Ardent.php:657

//    public function save(array $rules = array(),
//        array $customMessages = array(),
//        array $options = array(),
//        Closure $beforeSave = null,
//        Closure $afterSave = null
//    ) {
//        return $this->internalSave($rules, $customMessages, $options, $beforeSave, $afterSave, false);
//    }

    public function save(Array $arg1 = null)
    {
        if ($arg1 == null) {
           return $this->internalSave([], [], [], null, null, false);
        } else {
           return parent::save($arg1);
        }
    }

Eloquent has two different saves: Database/Eloquent/Model.php: public function save(array $options = []) Database/Eloquent/Relations/HasOneOrMany.php: public function save(Model $model) (also MorphOneOrMany and BelongsToMany)

I encountered this error when following the Laravel seeder documentation here: https://laravel.com/docs/5.5/seeding#writing-seeders

james-coder avatar Oct 23 '17 22:10 james-coder