Init: Hoan thanh kien truc V3 va Filament UI
This commit is contained in:
31
app/Models/Product.php
Normal file
31
app/Models/Product.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user