Comment.php 749 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Models\CustomArticle;
  3. use App\Models\User\UserModel;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Comment extends Model
  6. {
  7. //
  8. protected $table = "kdgx_custom_article_comments";
  9. public $dateFormat = 'U';
  10. protected $fillable = [
  11. 'article_id',
  12. 'uid',
  13. 'content',
  14. 'thumb',
  15. 'content',
  16. 'deleted_at',
  17. 'top_at',
  18. ];
  19. public function article()
  20. {
  21. return $this->belongsTo(Article::class);
  22. }
  23. public function user()
  24. {
  25. return $this->belongsTo(UserModel::class, 'uid', 'uid')->select('nickname', 'headimgurl');
  26. }
  27. public function reply()
  28. {
  29. return $this->hasOne(Reply::class, 'comment_id', 'id');
  30. }
  31. }