philipbrown / magniloquent

DEPRECATED, USE https://github.com/dwightwatson/validating
MIT License
70 stars 8 forks source link

Weird isValid behaviour #20

Closed etiennemarais closed 10 years ago

etiennemarais commented 10 years ago

When running the User::create($input). The isValid property is true all the way through the magniloquent model save() but sets it back to false in the UserRepository create()

//magniloquent.php

public function save(array $new_attributes = array(), $forceSave = false)
{
    ...
    var_dump($user->isValid()); // true
    return parent::save($options);
}

// EloquentUserRepository.php

public function create($input)
{
    $user = User::create($input);
    var_dump($user->isValid()); // false
    return $user;
}
w3irdrobot commented 10 years ago

I have located the issue. It lies in my setAttribute(). There is an attribute being set somewhere in the saving process that is throwing an error. I can look at this more tonight. Thank you for pointing this out.

w3irdrobot commented 10 years ago

Just to inform you. The issue was caused when the ID and dates were set on the model after validation and just before saving. The solution is now in place. Thank you for pointing this out!