FinanceRecord.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. class FinanceRecord extends Model
  6. {
  7. protected $fillable = [
  8. 'record_no',
  9. 'owner_type',
  10. 'agent_id',
  11. 'order_id',
  12. 'withdraw_id',
  13. 'recharge_id',
  14. 'type',
  15. 'business_type',
  16. 'amount',
  17. 'payment_type',
  18. 'region_code',
  19. 'user_id',
  20. 'coach_id',
  21. 'remark'
  22. ];
  23. protected $casts = [
  24. 'amount' => 'decimal:2',
  25. 'created_at' => 'datetime',
  26. 'updated_at' => 'datetime'
  27. ];
  28. /**
  29. * 关联订单
  30. */
  31. public function order(): BelongsTo
  32. {
  33. return $this->belongsTo(Order::class);
  34. }
  35. /**
  36. * 关联用户
  37. */
  38. public function user(): BelongsTo
  39. {
  40. return $this->belongsTo(MemberUser::class, 'user_id');
  41. }
  42. /**
  43. * 关联技师
  44. */
  45. public function coach(): BelongsTo
  46. {
  47. return $this->belongsTo(CoachUser::class, 'coach_id');
  48. }
  49. /**
  50. * 关联代理商
  51. */
  52. public function agent(): BelongsTo
  53. {
  54. return $this->belongsTo(AgentInfo::class, 'agent_id');
  55. }
  56. }