Tag.php 462 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Tag extends Model
  5. {
  6. protected $fillable = ['tag_name', 'article_number'];
  7. protected $table = 'tags';
  8. /**
  9. * tag 与 article 多对多关联
  10. *
  11. * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
  12. */
  13. public function article()
  14. {
  15. return $this->belongsToMany('App\Models\Article','article_tags', 'tag_id', 'article_id');
  16. }
  17. }