php - Laravel 中 isDirty() 是什么意思?

标签 php laravel

首先,我对 Laravel 不太熟悉(或者对“脏”这个词)不太熟悉。
我偶然发现了这行代码 -

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

我无法理解这到底意味着什么。我试图在互联网上查找,但 Laravel 网站只说了这一点

"Determine if a given attribute is dirty"

这并没有什么帮助......

最佳答案

当您想知道模型自从数据库查询以来是否已被编辑,或者根本没有保存时​​,您可以使用 ->isDirty()功能。

关于php - Laravel 中 isDirty() 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28836013/

相关文章:

php - 不在对象上下文中时使用 $this - Laravel 4

laravel phpunit 未知数据库':memory:

php - 如何在 Laravel/PHP 中将子项作为 json 从数据库插入父项?

php - Firebase FCM 错误 JSON_PARSING_ERROR : Unexpected token END OF FILE at position

java - SOAP 请求返回 wsdl 而不是预期的 SOAP 响应

php - https 旧 url 到同一网站中的新 https url

php - 在没有 auth.ini 的情况下在 PHP (Codeigniter) 中登录 Api AdWords

php - 无法在 Angular 2 中将数据从表单发布到 mysql

mysql - Laravel Eloquent 如何限制登录用户的访问权限

Laravel 5.2 传递中间件参数在服务提供者中注册服务容器