Laravel ignore mutators

Whereas the answers provided seems to work, there is a method in Laravel to access the original value:

$service->getOriginal('amount')

See this post: Example of getOriginal()

Api: API Documentation


Set a public variable in model, e.g $preventAttrSet

public $preventAttrSet = false;

public function setFirstNameAttribute($value) {
    if ($this->preventAttrSet) {
        // Ignore Mutator
        $this->attributes['first_name'] = $value;
    } else {
        $this->attributes['first_name'] = strtolower($value);
    }
}

Now you can set the public variable to true when want to Ignore Mutator according to your cases

$user = new User;
$user->preventAttrSet = true;
$user->first_name = 'Sally';
echo $user->first_name;