Đóng gói cuối tuần
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ProductType;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -12,20 +13,33 @@ class Product extends Model
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
// Ép kiểu JSON để Filament có thể đọc/ghi dữ liệu linh hoạt (tầng, hướng, mặt tiền...)
|
||||
protected $casts = [
|
||||
'product_type' => ProductType::class,
|
||||
'custom_data' => 'array',
|
||||
'infrastructure_status' => 'array',
|
||||
'area' => 'decimal:2',
|
||||
'price_per_unit' => 'decimal:2',
|
||||
'total_price' => 'decimal:2',
|
||||
'building_density' => 'decimal:2',
|
||||
];
|
||||
|
||||
// Khai báo mối quan hệ V3: 1 Sản phẩm thuộc về 1 Dự án
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
|
||||
// Đón đầu cho các bước tiếp theo: 1 Sản phẩm có nhiều Hợp đồng
|
||||
public function contracts()
|
||||
{
|
||||
return $this->hasMany(Contract::class);
|
||||
}
|
||||
}
|
||||
|
||||
public function settlements()
|
||||
{
|
||||
return $this->hasMany(Settlement::class);
|
||||
}
|
||||
|
||||
public function appendices()
|
||||
{
|
||||
return $this->hasMany(Appendix::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user