1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\models\article;
- use app\models\user\User;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- use think\model\relation\HasOne;
- /**
- * 文章详情
- * Class ArticleCategory
- * @package app\models\article
- */
- class ArticleReply extends BaseModel
- {
- use ModelTrait;
- public function user(): HasOne
- {
- return self::hasOne(User::class, 'uid', 'uid')->field('uid,nickname,avatar');
- }
- public function article(): HasOne
- {
- return self::hasOne(Article::class, 'id', 'aid')->field('*');
- }
-
- // 统计文章评论数
- public function counts($id)
- {
- $model = new self();
- $counts=$model::where('aid',$id)->count();
- return $counts;
- }
-
- }
|