/** * Toggle pin * * @param $id * @return bool|mixed */ public function togglePin($id) { $post = $this->post->findById($id); if (!$post) { return false; } $this->post->update($post, ['pinned' => $post->pinned ? false : true]); return $post; }