Skip to content

Commit 2c25c0b

Browse files
caothu159portal-bot
andcommitted
refactor(simba): move ArDmKh KH/NCC/NV scopes to catalog concern (#220)
Co-authored-by: portal-bot <bot@portal>
1 parent 460581a commit 2c25c0b

1 file changed

Lines changed: 7 additions & 49 deletions

File tree

src/Models/ArDmKh.php

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
/**
2323
* Model ArDmKh - Danh mục khách hàng.
2424
*
25-
* Mở rộng từ ArDmKhModel với các scope và helper methods.
25+
* Mở rộng từ ArDmKhModel với:
26+
* - Global scope ksd.
27+
* - Scope search/order theo field Simba.
28+
* - Quan hệ glCts, stored procedure AsGetSoDuKh.
29+
*
30+
* Phân loại KH/NCC/NV đã được tách sang
31+
* `Diepxuan\Catalog\Models\ArDmKh` (dùng `HasArDmKhCategories`).
2632
*/
2733
class ArDmKh extends Model
2834
{
@@ -41,30 +47,6 @@ protected static function booted(): void
4147
});
4248
}
4349

44-
/**
45-
* Scope: Chỉ lấy khách hàng (isKh = true).
46-
*/
47-
public function scopeLaKhachHang(Builder $query): Builder
48-
{
49-
return $query->where('isKh', true);
50-
}
51-
52-
/**
53-
* Scope: Chỉ lấy nhà cung cấp (isNcc = true).
54-
*/
55-
public function scopeLaNhaCungCap(Builder $query): Builder
56-
{
57-
return $query->where('isNcc', true);
58-
}
59-
60-
/**
61-
* Scope: Chỉ lấy nhân viên (isNv = true).
62-
*/
63-
public function scopeLaNhanVien(Builder $query): Builder
64-
{
65-
return $query->where('isNv', true);
66-
}
67-
6850
/**
6951
* Scope: Tìm kiếm theo mã khách hàng hoặc tên.
7052
*/
@@ -108,28 +90,4 @@ public static function AsGetSoDuKh(array $params): float
10890
'pTk' => $params['pTk'] ?? null,
10991
]);
11092
}
111-
112-
/**
113-
* Accessor: Kiểm tra có phải khách hàng không.
114-
*/
115-
public function getIsKhachHangAttribute(): bool
116-
{
117-
return (bool) $this->isKh;
118-
}
119-
120-
/**
121-
* Accessor: Kiểm tra có phải nhà cung cấp không.
122-
*/
123-
public function getIsNhaCungCapAttribute(): bool
124-
{
125-
return (bool) $this->isNcc;
126-
}
127-
128-
/**
129-
* Accessor: Kiểm tra có phải nhân viên không.
130-
*/
131-
public function getIsNhanVienAttribute(): bool
132-
{
133-
return (bool) $this->isNv;
134-
}
13593
}

0 commit comments

Comments
 (0)