From 447a74928bad562ec67d8df0113f39151db5ae84 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Nov 2013 10:11:40 -0500 Subject: [PATCH 01/11] Ditched parent ID - extraneous feature, not really needed --- ..._25_150450_drop_parent_from_categories.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php diff --git a/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php b/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php new file mode 100644 index 0000000000..be8d754a8d --- /dev/null +++ b/app/database/migrations/2013_11_25_150450_drop_parent_from_categories.php @@ -0,0 +1,30 @@ +dropColumn('parent'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } + +} \ No newline at end of file From 5a2c6391bfcf23aaeede3648251555f807eaf751 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Nov 2013 10:12:23 -0500 Subject: [PATCH 02/11] Added category relationship --- app/controllers/admin/CategoriesController.php | 5 +---- app/models/Category.php | 15 ++++++--------- app/models/Model.php | 7 ++++++- 3 files changed, 13 insertions(+), 14 deletions(-) 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'); + } + + } From 3ba2880a3552990869e0b68aa4315058fb5420d0 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Nov 2013 10:12:41 -0500 Subject: [PATCH 03/11] Layout tweaks --- app/views/backend/categories/edit.blade.php | 66 +++++++------- app/views/backend/categories/index.blade.php | 91 ++++++++++---------- app/views/backend/layouts/default.blade.php | 8 +- app/views/backend/models/index.blade.php | 4 +- 4 files changed, 87 insertions(+), 82 deletions(-) diff --git a/app/views/backend/categories/edit.blade.php b/app/views/backend/categories/edit.blade.php index 33a9fa13d7..6ae26b9680 100755 --- a/app/views/backend/categories/edit.blade.php +++ b/app/views/backend/categories/edit.blade.php @@ -12,46 +12,32 @@ {{-- Page content --}} @section('content') - +