What is the difference between $ this-> attributes and $ this-> original

I set a breakpoint inside a function in my model in Laravel 4.

I see that on $this there are attributes and the original .

Both seem to contain the same data, i.e. a key / value pair representing the fields in the table.

What's the difference?

I need a function in my model that will return all fields as an associative array that I use?

enter image description here

+4
source share
1 answer

They have the same data until you change any of your attributes:

 $user->name = "user391986"; 

Then you will have

 $user->attributes['name'] != $user->original['name']; 
+5
source

Source: https://habr.com/ru/post/1493837/


All Articles