user391986
user391986

Reputation: 30906

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

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

I see on $this there is both attributes and original.

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

What's the difference?

I need a function in my model that will return all the fields as an associative array, which one do I use?

enter image description here

Upvotes: 5

Views: 3719

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87769

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

$user->name = "user391986";

Then you'll have

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

Upvotes: 6

Related Questions