Payment.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /**
  7. * @property int $id
  8. * @property string $name
  9. * @property \Carbon\Carbon $created_at
  10. * @property \Carbon\Carbon $updated_at
  11. */
  12. class Payment extends Model
  13. {
  14. use HasFactory, SoftDeletes;
  15. protected $table = 'payments';
  16. protected $fillable = [
  17. 'schedule_id',
  18. 'client_id',
  19. 'provider_id',
  20. 'client_payment_method_id',
  21. 'gateway_provider',
  22. 'gateway_entity_reference',
  23. 'gateway_entity_label',
  24. 'gateway_operation_reference',
  25. 'gateway_operation_label',
  26. 'payment_method',
  27. 'status',
  28. 'gross_amount',
  29. 'gateway_fee_amount',
  30. 'platform_fee_amount',
  31. 'net_amount',
  32. 'currency',
  33. 'installments',
  34. 'authorized_at',
  35. 'paid_at',
  36. 'failed_at',
  37. 'cancelled_at',
  38. 'expires_at',
  39. 'failure_code',
  40. 'failure_message',
  41. 'gateway_payload',
  42. 'metadata',
  43. ];
  44. protected $casts = [
  45. 'gross_amount' => 'decimal:2',
  46. 'gateway_fee_amount' => 'decimal:2',
  47. 'platform_fee_amount' => 'decimal:2',
  48. 'net_amount' => 'decimal:2',
  49. 'installments' => 'integer',
  50. 'authorized_at' => 'datetime',
  51. 'paid_at' => 'datetime',
  52. 'failed_at' => 'datetime',
  53. 'cancelled_at' => 'datetime',
  54. 'expires_at' => 'datetime',
  55. 'gateway_payload' => 'array',
  56. 'metadata' => 'array',
  57. 'created_at' => 'datetime',
  58. 'updated_at' => 'datetime',
  59. 'deleted_at' => 'datetime',
  60. ];
  61. public function schedule()
  62. {
  63. return $this->belongsTo(Schedule::class);
  64. }
  65. public function client()
  66. {
  67. return $this->belongsTo(Client::class);
  68. }
  69. public function provider()
  70. {
  71. return $this->belongsTo(Provider::class);
  72. }
  73. public function clientPaymentMethod()
  74. {
  75. return $this->belongsTo(ClientPaymentMethod::class);
  76. }
  77. public function transfers()
  78. {
  79. return $this->hasMany(PaymentTransfer::class);
  80. }
  81. }