public function updateLikes() { $this->likes = NoteLike::where('note_id', $this->id)->count(); $this->save(); }
public static function exists($userId, $noteId) { return NoteLike::where('user_id', $userId)->where('note_id', $noteId)->count() > 0; }