laravel update shouldn't do anything if no value changed -


if open form edit , without changing value hit submit button update, updates row in table i.e. changes updated_at time , executes code in bootxxxx(static::saving(function($model) {}) function.

i not want happen.

how can find if user changed nothing , blank submit button hit?

of course before update can fetch current values , compare them input $request->all() , decide update or not, there better way laravel way?

thanks, k

you have 2 methods 1 getdirty() using current changed input value, 1 getoriginal() if use previous data have

by using 2 methods giving here example,may you

static::saving(function($model) { foreach($model->getdirty() $attribute => $value){     $original= $model->getoriginal($attribute);     echo "changed $attribute '$original' '$value'<br/>\r\n"; } return true; //if false model wont save!  }); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -