فهرست منبع

feat(unit-payable): model UnitAccountPayable com origem tbr/manual

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ebagabee 4 هفته پیش
والد
کامیت
96ea15f1a8
1فایلهای تغییر یافته به همراه59 افزوده شده و 0 حذف شده
  1. 59 0
      app/Models/UnitAccountPayable.php

+ 59 - 0
app/Models/UnitAccountPayable.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+/**
+ * @property int $id
+ * @property int $unit_id
+ * @property int|null $franchisee_account_receive_id
+ * @property string $origin
+ * @property string $history
+ * @property numeric $value
+ * @property numeric $paid_value
+ * @property numeric $discount
+ * @property numeric $fine
+ * @property \Illuminate\Support\Carbon $due_date
+ * @property \Illuminate\Support\Carbon|null $payment_date
+ * @property string $status
+ * @property string|null $obs
+ * @property-read \App\Models\Unit $unit
+ * @property-read \App\Models\FranchiseeAccountReceive|null $franchiseeAccountReceive
+ */
+class UnitAccountPayable extends Model
+{
+    use HasFactory, SoftDeletes;
+
+    public const ORIGIN_TBR    = 'tbr';
+    public const ORIGIN_MANUAL = 'manual';
+
+    protected $table = 'unit_account_payables';
+
+    protected $guarded = ['id'];
+
+    protected $casts = [
+        'value'        => 'decimal:2',
+        'paid_value'   => 'decimal:2',
+        'discount'     => 'decimal:2',
+        'fine'         => 'decimal:2',
+        'due_date'     => 'date',
+        'payment_date' => 'date',
+        'created_at'   => 'datetime',
+        'updated_at'   => 'datetime',
+        'deleted_at'   => 'datetime',
+    ];
+
+    public function unit(): BelongsTo
+    {
+        return $this->belongsTo(Unit::class, 'unit_id');
+    }
+
+    public function franchiseeAccountReceive(): BelongsTo
+    {
+        return $this->belongsTo(FranchiseeAccountReceive::class, 'franchisee_account_receive_id');
+    }
+}