public function previous() { return PostTagHistory::where("post_id = ? AND id < ?", $this->post_id, $this->id)->order("id ASC")->first(); }
protected function save_post_history() { $new_cached_tags = $this->cached_tags_versioned(); if ($this->tag_history->none() or $this->tag_history[0]->tags != $new_cached_tags) { PostTagHistory::create(['post_id' => $this->id, 'tags' => $new_cached_tags, 'user_id' => $this->user_id, 'ip_addr' => current_user() && current_user()->ip_addr ? current_user()->ip_addr : "127.0.0.1"]); } }