1,'is_top'=>0,'is_hot'=>0]; //仅更新有效 protected $update = ['update_time']; //软删除 use SoftDelete; protected $deleteTime = 'delete_time'; protected $defaultSoftDelete = 0; //文章关联栏目表 public function cate() { return $this->belongsTo('Cate','cate_id','id'); } //文章关联评论 public function comments() { return $this->hasMany(Comment::class); } //文章关联用户 public function user() { return $this->belongsTo('User','user_id','id'); } //文章添加 public function add($data) { $result = $this->save($data); if($result) { return 1; } else { return '文章添加失败!'; } } //文章编辑 public function edit($data) { $article = $this->find($data['id']); $result = $article->save($data); if($result) { return 1; } else { return '文章修改失败!'; } } //文章 public function detail() { $arts = Article::all(); return $arts; } //置顶文章 public function artTop() { $artTop = Article::where('status',1)->where('is_top',1)->select(); return $artTop; } }