mwa*_*afi 4 php laravel laravel-4
我试图让Getter&Setter Methods工作(来自Laravel 4中的Laravel 3)
但显示错误.
这附近有什么工作吗?
它们在密码案例中非常有用:
public function set_password($password)
{
$this->set_attribute('hashed_password', Hash::make($password));
}
Run Code Online (Sandbox Code Playgroud)
刚刚找到答案:
现在它称为Accessors&Mutators
https://laravel.com/docs/5.2/eloquent-mutators
在设置之前哈希密码:
public function setPasswordAttribute($pass)
{
$this->attributes['password'] = Hash::make($pass);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11223 次 |
| 最近记录: |