public function save(array $options = []) { if (empty($this->id)) { $this->id = self::max('id') + 1; } parent::save($options); }
/** * Deletes a blog post and all * the associated comments. * * @return bool */ public function delete() { // Delete the comments $this->comments()->delete(); // Delete the blog post return parent::delete(); }