Say I have a model Foo
and I'm mutating an attribute getter, like so:
class Foo extends Model
{
protected $table = 'foo';
public function getSomeBarAttribute($value)
{
return some_function($value);
}
}
Is there a way to access the attribute's raw value, pre-mutation?
The method you look for is getOriginal. To get the original value you might use:
$this->getOriginal('some_bar');
In model is defined this var:
/**
* The model attribute's original state.
*
* @var array
*/
protected $original = array();
It's protected so you should add a function to get original's values
(not tested)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With