first commit

This commit is contained in:
2025-12-30 15:03:19 +08:00
commit c735c36009
902 changed files with 83591 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class PurchaseOrderItem extends Model
{
use HasFactory;
protected $fillable = [
'purchase_order_id',
'product_id',
'quantity',
'unit_price',
'subtotal',
'received_quantity',
];
protected $casts = [
'quantity' => 'decimal:2',
'unit_price' => 'decimal:2',
'subtotal' => 'decimal:2',
'received_quantity' => 'decimal:2',
];
protected $appends = [
'productName',
'unit',
'productId',
'unitPrice',
];
public function getProductIdAttribute(): string
{
return (string) $this->attributes['product_id'];
}
public function getUnitPriceAttribute(): float
{
return (float) $this->attributes['unit_price'];
}
public function getProductNameAttribute(): string
{
return $this->product ? $this->product->name : '';
}
public function getUnitAttribute(): string
{
return $this->product ? $this->product->base_unit : '';
}
public function purchaseOrder(): BelongsTo
{
return $this->belongsTo(PurchaseOrder::class);
}
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
}