Course.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Repositories\Models\Course;
  3. use App\Repositories\Models\Model;
  4. use App\Repositories\Models\Base\Resource;
  5. use Prettus\Repository\Contracts\Transformable;
  6. use Prettus\Repository\Traits\TransformableTrait;
  7. /**
  8. * Class Course.
  9. *
  10. * @package namespace App\Repositories\Models;
  11. */
  12. class Course extends Model implements Transformable
  13. {
  14. use TransformableTrait;
  15. protected $table = 'course_courses';
  16. /**
  17. * The attributes that are mass assignable.
  18. *
  19. * @var array
  20. */
  21. protected $guarded = [];
  22. protected static function booted()
  23. {
  24. self::language();
  25. }
  26. public function category()
  27. {
  28. return $this->belongsTo(Category::class, 'category_id', 'id');
  29. }
  30. public function thumb_resource()
  31. {
  32. return $this->belongsTo(Resource::class, 'thumb', 'id')->select(['path', 'id', 'url']);
  33. }
  34. public function attaches()
  35. {
  36. return $this->hasMany(Attach::class, 'course_id', 'id');
  37. }
  38. public function subscribe()
  39. {
  40. return $this->hasOne(UserRecord::class);
  41. }
  42. public function comments()
  43. {
  44. return $this->hasMany(Comment::class);
  45. }
  46. }