perf(closet): update score after removing textures

This commit is contained in:
Pig Fang 2018-01-01 15:53:56 +08:00
parent 846f29ef6d
commit 49deeb3f99

View File

@ -55,7 +55,7 @@ class Closet
));
// traverse items in the closet
$this->textures->filter(function ($texture) use ($uid) {
$removedCount = $this->textures->filter(function ($texture) use ($uid) {
$t = Texture::find($texture['tid']);
// if the texture was deleted
@ -69,15 +69,16 @@ class Closet
return false;
})->each(function ($texture) use ($uid) {
// return scores if the texture was deleted or set as private
if (option('return_score')) {
app('users')->get($uid)->setScore(
option('score_per_closet_item'), 'plus'
);
}
$this->remove($texture['tid']);
});
})->count();
// return scores if the texture was deleted or set as private
if (option('return_score')) {
app('users')->get($uid)->setScore(
option('score_per_closet_item') * $removedCount,
'plus'
);
}
}
/**