modify an attribute when getting it in laravel model code example
Example 1: get original name without mutant model laravel
Inside your model file:
1. In laravel older versions (5.x and older):
$this->getOriginal('name');
2. In laravel latest versions (6.x and above):
$model->getRawOriginal('name');
Alternative methods for getting value with mutator:
1. $this->attributes['name']
2. $this->getAttributes()['name']`
Example 2: laravel property
$user = User::create(array('name' => 'John'));
$user = User::firstOrCreate(array('name' => 'John'));
$user = User::firstOrNew(array('name' => 'John'));