Article.php 494 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Article extends Model
  5. {
  6. protected $fillable = ['category_id','title','keywords','description','content','thumb','click'];
  7. //文章所属分类
  8. public function category()
  9. {
  10. return $this->belongsTo('App\Models\Category');
  11. }
  12. //与标签多对多关联
  13. public function tags()
  14. {
  15. return $this->belongsToMany('App\Models\Tag','article_tag','article_id','tag_id');
  16. }
  17. }