use model observer to manage tagging of notes
This commit is contained in:
parent
14cba19903
commit
467b607774
3 changed files with 79 additions and 17 deletions
18
app/Tag.php
18
app/Tag.php
|
@ -6,13 +6,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Tag extends Model
|
||||
{
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'tags';
|
||||
|
||||
/**
|
||||
* Define the relationship with tags.
|
||||
*
|
||||
|
@ -31,13 +24,6 @@ class Tag extends Model
|
|||
return $this->belongsToMany('App\Bookmark');
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['deleted'];
|
||||
|
||||
/**
|
||||
* We shall set a blacklist of non-modifiable model attributes.
|
||||
*
|
||||
|
@ -52,7 +38,7 @@ class Tag extends Model
|
|||
*/
|
||||
public function setTagAttribute($value)
|
||||
{
|
||||
$this->attributes['tag'] = $this->normalizeTag($value);
|
||||
$this->attributes['tag'] = $this->normalize($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +47,7 @@ class Tag extends Model
|
|||
*
|
||||
* @param string
|
||||
*/
|
||||
public static function normalizeTag($tag)
|
||||
public static function normalize($tag)
|
||||
{
|
||||
return mb_strtolower(
|
||||
preg_replace(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue