public function get_blocks() { return $this->blocks->where('parent', '=', 0)->find_all(); } public function delete() { if ((bool) $this->tags->count_all()) { foreach ($this->tags->find_all() as $tag) { $this->remove('tags', $tag); } } if ((bool) $this->blocks->count_all()) { foreach ($this->blocks->find_all() as $block) { $block->delete(); } } if ((bool) $this->categories->count_all()) { foreach ($this->categories->find_all() as $category) { $this->remove('categories', $category); } } $kids = ORM::factory('Content')->where('parent', '=', $this->id)->find_all(); if ((bool) $kids->count()) { foreach ($kids as $kid) { $kid->parent = 0; $this->check_slug_and_guid(); $kid->save(); } } // Splittests $tests = ORM::factory('Content')->where('splittest', '=', $this->id)->find_all(); if ((bool) $tests->count()) { foreach ($tests as $test) { $test->delete();