Added category relationship
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user