Andrii Andrii - 3 years ago 134
PHP Question

Laravel 5.4 Accessors doesn't work

I have a User Eloquent model with attribute phone_1

here are method, but it does not work:

public function getPhone1Attribute($value)
{
xdebug_break();
if ($value !== null) {
return $this->formatPhone($value);
}
return $value;
}

Answer Source

Mutator not working for if starting letter integer.Since mutator take first letter as capital so you cant assign 1 since we cant make interger to capital

suppose if you change phone_1 to phone_one then it will work

public function getPhoneOneAttribute($value){
}

if you change phone_1 to phone_o1ne then it will work.since here p and o are letters for that

public function getPhoneO1neAttribute($value){
    }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download