tags.normalized_name

This commit is contained in:
shibafu
2020-07-30 22:42:10 +09:00
parent c7aa002625
commit e2c43fef80
4 changed files with 61 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
namespace App;
use App\Utilities\Formatter;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model
@@ -15,6 +16,15 @@ class Tag extends Model
'name'
];
protected static function boot()
{
parent::boot();
self::creating(function (Tag $tag) {
$tag->normalized_name = app(Formatter::class)->normalizeTagName($tag->name);
});
}
public function ejaculations()
{
return $this->belongsToMany('App\Ejaculation')->withTimestamps();