5

I tried to get Getter & Setter Methods work (from Laravel 3 in Laravel 4)

but display Error.

is there any work around here?

they are very useful in password case:

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

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

The Alpha
  • 143,660
  • 29
  • 287
  • 307
mwafi
  • 3,946
  • 8
  • 56
  • 83

1 Answers1

9

Just found the answer:

Now it called Accessors & Mutators

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

to hash password before you set it:

public function setPasswordAttribute($pass)
{
    $this->attributes['password'] = Hash::make($pass);
}
Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231
mwafi
  • 3,946
  • 8
  • 56
  • 83
  • Does exist a classic OOP getters and setters declaration for Eloquent model instead of have a look every time on the related Database table? –  Aug 28 '16 at 20:07