Skip to content

Commit

Permalink
Update updated_at column when updating counter
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Aug 18, 2023
1 parent 43aae56 commit 43c68fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use App\Libraries\MorphMap;
use App\Traits\Validatable;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;

/**
Expand Down Expand Up @@ -254,7 +255,7 @@ public function save(array $options = [])
return $this->getConnection()->transaction(function () use ($options) {
if (!$this->exists && $this->parent_id !== null && $this->parent !== null) {
// skips validation and everything
$this->parent->incrementInstance('replies_count_cache');
$this->parent->incrementInstance('replies_count_cache', 1, ['updated_at' => Carbon::now()]);
}

if ($this->isDirty('deleted_at')) {
Expand Down

0 comments on commit 43c68fb

Please sign in to comment.