Update StatusHashtagObserver

This commit is contained in:
Daniel Supernault 2022-12-27 04:16:34 -07:00
parent 4fd12b063b
commit 29f2c50e2e
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -2,6 +2,7 @@
namespace App\Observers; namespace App\Observers;
use DB;
use App\StatusHashtag; use App\StatusHashtag;
use App\Services\StatusHashtagService; use App\Services\StatusHashtagService;
@ -23,6 +24,7 @@ class StatusHashtagObserver
public function created(StatusHashtag $hashtag) public function created(StatusHashtag $hashtag)
{ {
StatusHashtagService::set($hashtag->hashtag_id, $hashtag->status_id); StatusHashtagService::set($hashtag->hashtag_id, $hashtag->status_id);
DB::table('hashtags')->where('id', $hashtag->hashtag_id)->increment('cached_count');
} }
/** /**
@ -45,6 +47,7 @@ class StatusHashtagObserver
public function deleted(StatusHashtag $hashtag) public function deleted(StatusHashtag $hashtag)
{ {
StatusHashtagService::del($hashtag->hashtag_id, $hashtag->status_id); StatusHashtagService::del($hashtag->hashtag_id, $hashtag->status_id);
DB::table('hashtags')->where('id', $hashtag->hashtag_id)->decrement('cached_count');
} }
/** /**