Search code examples
resourceslaravel-nova

Laravel Nova: bypass accessor to getOriginal


When using Laravel Nova you may expect $this->getOriginal('name') to bypass an accessor to return the database value of name. However, this is not the case.

Text::make('Name')
    ->resolveUsing(function(){
        return $this->getOriginal('name')
    });

// Returns value provided by accessor

Solution

  • To access the actual original property use getRawOriginal()

    Text::make('Name')
        ->resolveUsing(function(){
            return $this->getRawOriginal('name')
        });
    
    // Returns value from database