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

How to pass valiables to 404 error page in laravel?
Publish date: 2022-02-21 | Comments: 2
Laravel Network is unreachable stream_socket_client 587
Publish date: 2022-02-16 | Comments: 4
I want to make multiple foreign keys in Laravel, can I?
Publish date: 2022-01-27 | Comments: 5
Increase Sanctum token length in Laravel x9
Publish date: 2022-07-16 | Comments: 2