Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does isDirty() mean in Laravel?

Tags:

First of all, I am not familiar with Laravel so much (or with the term "dirty" for that matter).
I stumbled upon this line of code -

if ($this->isDirty('status')) {     if (Notification::has('website-status-' . strtolower($this->status))) {         Notification::set($this->account, 'website-status-' . strtolower($this->status), $this->emailAttributes())             ->email();     } } 

And I couldn't understand what that means exactly. I tried to find out on the internet but the Laravel site only says this

"Determine if a given attribute is dirty"

which doesn't really help...

like image 572
shay.k Avatar asked Mar 03 '15 15:03

shay.k


1 Answers

When you want to know if the model has been edited since it was queried from the database, or isn't saved at all, then you use the ->isDirty() function.

like image 111
nickforall Avatar answered Oct 07 '22 13:10

nickforall