48 lines
942 B
PHP
48 lines
942 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Cachet.
|
|
*
|
|
* (c) Cachet HQ <support@cachethq.io>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace CachetHQ\Cachet\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Tag extends Model
|
|
{
|
|
/**
|
|
* The fillable properties.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected $fillable = ['name'];
|
|
|
|
/**
|
|
* Overrides the models boot method.
|
|
*/
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
self::creating(function ($tag) {
|
|
$tag->slug = Str::slug($tag->name);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Tags can have many components.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
*/
|
|
public function components()
|
|
{
|
|
return $this->belongsToMany('CachetHQ\Cachet\Models\Component');
|
|
}
|
|
}
|