mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 05:28:18 +01:00
Make Taggable trait for simpleness
This commit is contained in:
parent
23f7d58010
commit
34c1bff186
@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Models;
|
||||
use AltThree\Validator\ValidatingTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SearchableTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SortableTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\Taggable;
|
||||
use CachetHQ\Cachet\Presenters\ComponentPresenter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -22,7 +23,7 @@ use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
|
||||
class Component extends Model implements HasPresenter
|
||||
{
|
||||
use SearchableTrait, SoftDeletes, SortableTrait, ValidatingTrait;
|
||||
use SearchableTrait, SoftDeletes, SortableTrait, Taggable, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* List of attributes that have default values.
|
||||
@ -143,16 +144,6 @@ class Component extends Model implements HasPresenter
|
||||
return $this->morphMany(Meta::class, 'meta');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tags relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
return $this->morphMany(Taggable::class, 'taggable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all components by status.
|
||||
*
|
||||
|
@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Models;
|
||||
use AltThree\Validator\ValidatingTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SearchableTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SortableTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\Taggable;
|
||||
use CachetHQ\Cachet\Presenters\IncidentPresenter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -29,7 +30,7 @@ use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
*/
|
||||
class Incident extends Model implements HasPresenter
|
||||
{
|
||||
use SearchableTrait, SoftDeletes, SortableTrait, ValidatingTrait;
|
||||
use SearchableTrait, SoftDeletes, SortableTrait, Taggable, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Status for incident being investigated.
|
||||
@ -177,16 +178,6 @@ class Incident extends Model implements HasPresenter
|
||||
return $this->morphMany(Meta::class, 'meta');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tags relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
return $this->morphMany(Taggable::class, 'taggable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updates relation.
|
||||
*
|
||||
|
32
app/Models/Traits/Taggable.php
Normal file
32
app/Models/Traits/Taggable.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Models\Traits;
|
||||
|
||||
use CachetHQ\Cachet\Models\Taggable as TaggableModel;
|
||||
|
||||
/**
|
||||
* This is the taggable trait.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
trait Taggable
|
||||
{
|
||||
/**
|
||||
* Get the tags relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
return $this->morphMany(TaggableModel::class, 'taggable');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user