Get original attributes after mutating an Eloquent record

Get original attributes after mutating an Eloquent record you can get the original attributes by calling getOriginal()

1$user = App\User::first();
2$user->name; // John
3$user->name = "Peter"; // Peter
4$user->getOriginal('name'); // John
5$user->getOriginal(); // Original $user record

Tip given by @devThaer

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord