✏️ 编辑:Tag.php
路径:
/home/boguraj1/.trash/app/Models/Tag.php
大小:515 B · 修改:2026-07-23 16:13:46 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; class Tag extends Model { protected $fillable = ['name', 'slug']; protected static function boot() { parent::boot(); static::creating(function ($tag) { if (empty($tag->slug)) { $tag->slug = Str::slug($tag->name); } }); } public function products() { return $this->belongsToMany(Product::class, 'product_tag'); } }
💾 保存
取消
保存为 UTF-8,换行统一为 LF