user image

Yasen Sayed
Published in : 2022-02-23

How to get original attribute value in Laravel?


Hello guys, Please anyone can help me to get the original attribute in Laravel?


Mahmoud Santos Date : 2022-02-23

Best answers


Best answers


You can try this I hope this will help you.


Also, you can do this if you like to get attributes only.



Yasen Sayed Date : 2022-02-23

Oh, How interesting it's worked successfully.


Thanks a lot 

Shilpa Date : 2022-02-26

Best answers


Best answers


If you are using laravel v5.0+ then this will help you for sure.

$originalArr= $model->getOriginal('arg1');

getOriginal() method is intended to bring original value of the attribute, which was loaded from the db. Also note that, If you change the value it will not work!

In such cases, For good practices, you may need

$originalArr= $model->setSomeArg('arg2');

This will preserve value in the $originalArr array.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Laravel API POST method returns 419
Publish date: 2022-08-03 | Comments: 1
Undefined Variable problem on Laravel 9.x
Publish date: 2022-03-06 | Comments: 3
Increase Sanctum token length in Laravel x9
Publish date: 2022-07-16 | Comments: 2
[solved] All assets in laravel storage returns 404
Publish date: 2021-12-14 | Comments: 2