/** * Detach all posts from a single category * * @param $categoryId * @return bool|mixed */ public function detachAllFromCategory($categoryId) { $category = $this->category->find($categoryId); if ($category) { $category->posts()->detach(); return true; } return false; }
public function action_edit() { $category = \Blog\Models\Category::find(Input::get('id')); $attribute = Input::get('type'); $value = Input::get('value'); if ($attribute == 'slug') { $value = Str::slug($value); } $category->{$attribute} = trim($value); $category->save(); return trim($value); }