Comment.php 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Repositories\Models\Course;
  3. use App\Repositories\Models\Model;
  4. use App\Repositories\Models\Base\User;
  5. use Prettus\Repository\Contracts\Transformable;
  6. use Prettus\Repository\Traits\TransformableTrait;
  7. /**
  8. * Class CourseComment.
  9. *
  10. * @package namespace App\Repositories\Models;
  11. */
  12. class Comment extends Model implements Transformable
  13. {
  14. use TransformableTrait;
  15. protected $table = 'course_comments';
  16. /**
  17. * The attributes that are mass assignable.
  18. *
  19. * @var array
  20. */
  21. protected $guarded = [];
  22. public function user()
  23. {
  24. return $this->belongsTo(User::class, 'user_id', 'id')->select(['id', 'name', 'username', 'mobile']);
  25. }
  26. public function course()
  27. {
  28. return $this->belongsTo(Course::class)->with(['thumb_resource'])->select(['id', 'title', 'thumb', 'labels']);
  29. }
  30. public function video()
  31. {
  32. return $this->belongsTo(Video::class)->select(['id', 'title']);
  33. }
  34. }