Laravel 4: Getter and Setter Methods

I tried using the Getter and Setter methods (from Laravel 3 to Laravel 4)

but display an error message.

Is there any work here?

they are very useful in the case of a password:

public function set_password($password)
{
    $this->set_attribute('hashed_password', Hash::make($password));
}

http://three.laravel.com/docs/database/eloquent

+4
source share
1 answer

Just found the answer:

Now it is called Accessors and Mutators.

https://laravel.com/docs/5.2/eloquent-mutators

before the hash password before setting it:

public function setPasswordAttribute($pass)
{
    $this->attributes['password'] = Hash::make($pass);
}
+9
source

Source: https://habr.com/ru/post/1541206/


All Articles