我正在运行这里找到的 Laravel 4 Ardent 包: https ://github.com/laravelbook/ardent
我正在尝试将 Ardent 的 README 中的代码集成到我的用户模型中:
public function beforeSave( $forced )
{
    // if there's a new password, hash it
    if($this->changed('password'))
    {
        $this->password = Hash::make($this->password);
    }
    return true;
}
我的用户模型测试:
public function testSetPassword() 
{
    // Create a new User
    $user = new User;
    $user->email = "joe@smalls.com";
    $user->password = "password";
    $user->password_confirmation = "password";
    $user->save();
    /* Test #1 - Test to make sure password is being hashed */
    $this->assertTrue(Hash::check('password', $user->password), "the set_password() function did not return TRUE");
}
当我通过 PhpUnit 进行测试时,它告诉我 '$this->changed()' 是未定义的。
BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::changed()
我基本上是按照教程所说的那样做,并在将密码保存到数据库之前检查以确保密码已更改。任何帮助将不胜感激。