Skip to content

Implement isDirty#74

Merged
DarkSide666 merged 4 commits intodevelopfrom
feature/implement-isDirty
Jul 25, 2016
Merged

Implement isDirty#74
DarkSide666 merged 4 commits intodevelopfrom
feature/implement-isDirty

Conversation

@romaninsh
Copy link
Copy Markdown
Member

@romaninsh romaninsh commented Jul 25, 2016

Apart from few minor fixes, this PR introduce a new method:

if ($m->isDirty(['name','surname'])) {
   $m['full_name'] = $m['name'].' '.$m['surname'];
}

When the code above is placed in beforeSave hook, it will only be executed when certain fields have been changed. If your recalculations are expensive, it's pretty handy to rely on "dirty" fields to avoid some complex logic.

@DarkSide666 DarkSide666 merged commit 94d9327 into develop Jul 25, 2016
@DarkSide666 DarkSide666 deleted the feature/implement-isDirty branch July 25, 2016 23:25
@romaninsh romaninsh restored the feature/implement-isDirty branch August 19, 2016 10:22
@romaninsh romaninsh deleted the feature/implement-isDirty branch August 19, 2016 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants