Component Groups. Closes #146.

This commit is contained in:
James Brooks
2015-01-04 20:56:10 +00:00
parent 35c0d25112
commit 0846cfdbca
12 changed files with 305 additions and 2 deletions

View File

@@ -43,7 +43,26 @@ class Component extends Model implements TransformableInterface
*
* @var string[]
*/
protected $fillable = ['name', 'description', 'status', 'user_id', 'tags', 'link', 'order'];
protected $fillable = [
'name',
'description',
'status',
'user_id',
'tags',
'link',
'order',
'group_id',
];
/**
* Components can belong to a group.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function group()
{
return $this->belongsTo('CachetHQ\Cachet\Models\ComponentGroup', 'group_id', 'id');
}
/**
* Lookup all of the incidents reported on the component.

View File

@@ -0,0 +1,45 @@
<?php
namespace CachetHQ\Cachet\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
/**
* @property int $id
* @property int $component_id
* @property int $group_id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
class ComponentGroup extends Model
{
use SoftDeletingTrait, ValidatingTrait;
/**
* The validation rules.
*
* @var string[]
*/
protected $rules = [
'name' => 'required|unique:component_groups',
];
/**
* The fillable properties.
*
* @var string[]
*/
protected $fillable = ['name'];
/**
* A group can have many components.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function components()
{
return $this->hasMany('CachetHQ\Cachet\Models\Component', 'id', 'group_id');
}
}