-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathArticle.php
More file actions
46 lines (40 loc) · 910 Bytes
/
Article.php
File metadata and controls
46 lines (40 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'title', 'cover', 'content_raw', 'content_html', 'is_top', 'is_hidden', 'view', 'comment','cate_id'
];
/**
* 获得此博客文章的评论
*/
public function comments()
{
return $this->hasMany('App\Comment');
}
/**
* 获得此博客文章的标签
*/
public function tags()
{
return $this->belongsToMany('App\Tag');
}
/**
* 更新评论量
* @var [int]
*/
static public function update_comment($id)
{
$article = Article::findOrFail($id);
$article->comment = $article->comment + 1;
$article->update([
'comment' => $article->comment,
]);
}
}