| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * @property int $id
- * @property int $student_contract_id
- * @property int $unit_id
- * @property int $student_id
- * @property string $type enrollment | package
- * @property string $history REF. MATRÍCULA | REF. PACOTE
- * @property int $installment_number
- * @property int $total_installments
- * @property float $value
- * @property float $paid_value
- * @property float $discount
- * @property float $fine
- * @property string $due_date
- * @property string|null $payment_date
- * @property string|null $cancelled_at
- * @property string|null $cancellation_reason
- * @property string|null $asaas_id
- * @property string $status pending | paid | cancelled
- */
- class StudentContractInstallment extends Model
- {
- use HasFactory, SoftDeletes;
- protected $table = 'student_contract_installments';
- protected $guarded = ['id'];
- protected $casts = [
- 'value' => 'float',
- 'paid_value' => 'float',
- 'discount' => 'float',
- 'fine' => 'float',
- 'due_date' => 'date:Y-m-d',
- 'payment_date' => 'date:Y-m-d',
- 'cancelled_at' => 'datetime',
- 'created_at' => 'datetime',
- 'updated_at' => 'datetime',
- ];
- /** Retorna a ordem formatada, ex: "1/12" */
- public function getOrderAttribute(): string
- {
- return "{$this->installment_number}/{$this->total_installments}";
- }
- public function studentContract(): BelongsTo
- {
- return $this->belongsTo(StudentContract::class);
- }
- public function unit(): BelongsTo
- {
- return $this->belongsTo(Unit::class);
- }
- public function student(): BelongsTo
- {
- return $this->belongsTo(Student::class);
- }
- }
|