Comment.php 854 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Repositories\Models\Note;
  3. use App\Repositories\Models\Model;
  4. use App\Repositories\Models\User\User;
  5. use Prettus\Repository\Contracts\Transformable;
  6. use Prettus\Repository\Traits\TransformableTrait;
  7. /**
  8. * Class Comment.
  9. *
  10. * @package namespace App\Repositories\Models\Note;
  11. */
  12. class Comment extends Model implements Transformable
  13. {
  14. use TransformableTrait;
  15. protected $table = 'node_comments';
  16. protected $guarded = [];
  17. protected static function booted()
  18. {
  19. self::language();
  20. }
  21. public function user()
  22. {
  23. return $this->belongsTo(User::class)->select(['id', 'name', 'headimg']);
  24. }
  25. public function note()
  26. {
  27. return $this->belongsTo(Note::class);
  28. }
  29. public function comments()
  30. {
  31. return $this->hasMany(Comment::class, 'parent_id', 'id');
  32. }
  33. }