diff --git a/app/controllers/admin/CategoriesController.php b/app/controllers/admin/CategoriesController.php index 2750eb24f9..245e950c02 100644 --- a/app/controllers/admin/CategoriesController.php +++ b/app/controllers/admin/CategoriesController.php @@ -38,8 +38,7 @@ class CategoriesController extends AdminController { public function getCreate() { // Show the page - $category_options = array('0' => 'Top Level') + Category::lists('name', 'id'); - return View::make('backend/categories/edit')->with('category_options',$category_options)->with('category',new Category); + return View::make('backend/categories/edit')->with('category',new Category); } @@ -63,7 +62,6 @@ class CategoriesController extends AdminController { // Update the category data $category->name = e(Input::get('name')); - $category->parent = e(Input::get('parent')); $category->user_id = Sentry::getId(); // Was the asset created? @@ -134,7 +132,6 @@ class CategoriesController extends AdminController { // Update the category data $category->name = e(Input::get('name')); - $category->parent = e(Input::get('parent')); // Was the asset created? if($category->save()) diff --git a/app/models/Category.php b/app/models/Category.php index fc5e117358..2c6943e444 100644 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -12,20 +12,17 @@ class Category extends Elegant { ); - - /** - * Get the parent category name - */ - public function parentname() - { - return $this->belongsTo('Category','parent'); - } - public function has_models() { return $this->hasMany('Model', 'category_id')->count(); } + public function models() + { + return $this->hasMany('Model', 'category_id'); + + } + } diff --git a/app/models/Model.php b/app/models/Model.php index 6508caed4a..04bc114c77 100644 --- a/app/models/Model.php +++ b/app/models/Model.php @@ -10,7 +10,12 @@ class Model extends Elegant { public function assets() { return $this->hasMany('Asset', 'model_id'); - } + public function category() + { + return $this->belongsTo('Category', 'category_id'); + } + + }