Answers for "eloquent is dirty"

PHP
1

laravel model is dirty

if($product->isDirty()){
    // changes have been made
}
Posted by: Guest on December-28-2020
0

check if value change laravel

If you want to check if the model is dirty just call isDirty():

if($product->isDirty()){
    // changes have been made
}
Or if you want to check a certain attribute:

if($product->isDirty('price')){
    // price has changed
}

refrence: https://stackoverflow.com/questions/28866500/laravel-eloquent-update-just-if-changes-have-been-made
Posted by: Guest on January-17-2021

Browse Popular Code Answers by Language