Accessor Not Being Executed

Posted 1 year ago by vkronlein

I have basic status accessor and mutator for a status checkbox like so:

public function setStatusAttribute($value)
{
    $this->attribute['status'] = ($value === 'on') ? 1 : -1;
}

public function getStatusAttribute($value)
{
    $status = ($value === 1) ? 'on' : 'off';

    return $status;
}

When I fetch a copy of the model my status still is -1

I've tried it via route model binding (which is my preferred method) and by just calling the model inside the method as well.

Why is it not get mutated?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.