UnitAccountReceivable.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. /**
  8. * Contas a Receber avulsas da unidade (lançamentos manuais, aluno opcional).
  9. *
  10. * @property int $id
  11. * @property int $unit_id
  12. * @property int|null $student_id
  13. * @property int|null $financial_plan_account_id
  14. * @property string $origin
  15. * @property string $history
  16. * @property numeric $value
  17. * @property numeric $paid_value
  18. * @property numeric $discount
  19. * @property numeric $fine
  20. * @property \Illuminate\Support\Carbon $due_date
  21. * @property \Illuminate\Support\Carbon|null $payment_date
  22. * @property string $status
  23. * @property string|null $obs
  24. */
  25. class UnitAccountReceivable extends Model
  26. {
  27. use HasFactory, SoftDeletes;
  28. public const ORIGIN_MANUAL = 'manual';
  29. protected $table = 'unit_account_receivables';
  30. protected $guarded = ['id'];
  31. protected $casts = [
  32. 'value' => 'decimal:2',
  33. 'paid_value' => 'decimal:2',
  34. 'discount' => 'decimal:2',
  35. 'fine' => 'decimal:2',
  36. 'due_date' => 'date',
  37. 'payment_date' => 'date',
  38. 'created_at' => 'datetime',
  39. 'updated_at' => 'datetime',
  40. 'deleted_at' => 'datetime',
  41. ];
  42. public function unit(): BelongsTo
  43. {
  44. return $this->belongsTo(Unit::class, 'unit_id');
  45. }
  46. public function student(): BelongsTo
  47. {
  48. return $this->belongsTo(Student::class, 'student_id');
  49. }
  50. public function planAccount(): BelongsTo
  51. {
  52. return $this->belongsTo(FinancialPlanAccount::class, 'financial_plan_account_id');
  53. }
  54. }