Tag.php 614 B

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