Tag syncing is now done within the Component commands
This commit is contained in:
@@ -55,4 +55,31 @@ class Tag extends Model
|
||||
{
|
||||
return $this->belongsToMany(Component::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|\ArrayAccess $values
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Tag|static
|
||||
*/
|
||||
public static function findOrCreate($values)
|
||||
{
|
||||
$tags = collect($values)->map(function ($value) {
|
||||
if ($value instanceof Tag) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$tag = static::where('name', '=', $value)->first();
|
||||
|
||||
if (!$tag instanceof Tag) {
|
||||
$tag = static::create([
|
||||
'name' => $value,
|
||||
'slug' => Str::slug($value),
|
||||
]);
|
||||
}
|
||||
|
||||
return $tag;
|
||||
});
|
||||
|
||||
return is_string($values) ? $tags->first() : $tags;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user