31 lines
807 B
PHP
31 lines
807 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Product extends Model
|
|
{
|
|
use HasUuids, HasFactory;
|
|
|
|
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 = [
|
|
'custom_data' => 'array',
|
|
];
|
|
|
|
// 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);
|
|
}
|
|
} |