| 123456789101112131415161718192021222324252627 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- class Tag extends Model implements Transformable
- {
- use TransformableTrait;
- protected $fillable = ['tag_name', 'article_number'];
- protected $table = 'tags';
- /**
- * tag 与 article 多对多关联
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
- */
- public function article()
- {
- return $this->belongsToMany('App\Models\Article','article_tags', 'tag_id', 'article_id');
- }
- }
|