Component Groups. Closes #146.
This commit is contained in:
@@ -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.
|
||||
|
||||
45
src/Models/ComponentGroup.php
Normal file
45
src/Models/ComponentGroup.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user