Home > database >  Get record real value after overriding it
Get record real value after overriding it

Time:02-10

I've overridden a a record value like the following :

public function getWeightAttribute($weight)
 {
        if($weight)
        {
          return $weight;
        }

        return 70;
}

Now I have a collection of that model and I want to know if the original value was null or not. I want to do it without connecting to DB again, Actually I want to make sure the user has filled the weight and some other fields while registering. Some sections are working based on the above override and I don't want to mess them up neither use extra connections to db. Thanks In Advance,

CodePudding user response:

In order to get original value you should can use:-

$fetchData->getAttributes()['weight'];

  • Related