Yasen Sayed
23 Feb 2022
Laravel
Hello guys, Please anyone can help me to get the original attribute in Laravel?
Mahmoud Santos
23 Feb 2022
Best Answer
You can try this I hope this will help you.
Model::first()->getOriginal()
Also, you can do this if you like to get attributes only.
Model::first()->getAttributes();
Yasen Sayed
23 Feb 2022
Oh, How interesting it's worked successfully.
Thanks a lot
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.
© 2024 Copyrights reserved for web-brackets.com