CoachOrderComment.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. class CoachOrderComment extends Model
  7. {
  8. use HasFactory, SoftDeletes;
  9. protected $table = 'coach_order_comments';
  10. protected $fillable = [
  11. 'order_id',
  12. 'user_id',
  13. 'coach_id',
  14. 'score',
  15. 'content',
  16. 'images',
  17. 'is_anonymous',
  18. 'status',
  19. ];
  20. protected $casts = [
  21. 'images' => 'array',
  22. 'score' => 'integer',
  23. 'is_anonymous' => 'boolean',
  24. 'status' => 'integer',
  25. ];
  26. /**
  27. * 获取评价的标签
  28. */
  29. public function tags()
  30. {
  31. return $this->belongsToMany(CoachCommentTag::class, 'coach_order_comment_tags', 'comment_id', 'tag_id')
  32. ->withTimestamps();
  33. }
  34. /**
  35. * 获取评价的用户
  36. */
  37. public function user()
  38. {
  39. return $this->belongsTo(MemberUser::class, 'user_id');
  40. }
  41. /**
  42. * 获取评价的技师
  43. */
  44. public function coach()
  45. {
  46. return $this->belongsTo(CoachUser::class, 'coach_id');
  47. }
  48. /**
  49. * 获取评价的订单
  50. */
  51. public function order()
  52. {
  53. return $this->belongsTo(Order::class, 'order_id');
  54. }
  55. }