StudentContractInstallment.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  7. /**
  8. * @property int $id
  9. * @property int $student_contract_id
  10. * @property int $unit_id
  11. * @property int $student_id
  12. * @property string $type enrollment | package
  13. * @property string $history REF. MATRÍCULA | REF. PACOTE
  14. * @property int $installment_number
  15. * @property int $total_installments
  16. * @property float $value
  17. * @property float $paid_value
  18. * @property float $discount
  19. * @property float $fine
  20. * @property string $due_date
  21. * @property string|null $payment_date
  22. * @property string|null $cancelled_at
  23. * @property string|null $cancellation_reason
  24. * @property string|null $asaas_id
  25. * @property string $status pending | paid | cancelled
  26. */
  27. class StudentContractInstallment extends Model
  28. {
  29. use HasFactory, SoftDeletes;
  30. protected $table = 'student_contract_installments';
  31. protected $guarded = ['id'];
  32. protected $casts = [
  33. 'value' => 'float',
  34. 'paid_value' => 'float',
  35. 'discount' => 'float',
  36. 'fine' => 'float',
  37. 'due_date' => 'date:Y-m-d',
  38. 'payment_date' => 'date:Y-m-d',
  39. 'cancelled_at' => 'datetime',
  40. 'created_at' => 'datetime',
  41. 'updated_at' => 'datetime',
  42. ];
  43. /** Retorna a ordem formatada, ex: "1/12" */
  44. public function getOrderAttribute(): string
  45. {
  46. return "{$this->installment_number}/{$this->total_installments}";
  47. }
  48. public function studentContract(): BelongsTo
  49. {
  50. return $this->belongsTo(StudentContract::class);
  51. }
  52. public function unit(): BelongsTo
  53. {
  54. return $this->belongsTo(Unit::class);
  55. }
  56. public function student(): BelongsTo
  57. {
  58. return $this->belongsTo(Student::class);
  59. }
  60. }