Skip to content

Commit b7f879f

Browse files
committed
feat: add Dmkho component and view, update routing and model references
1 parent ee661f1 commit b7f879f

3 files changed

Lines changed: 81 additions & 6 deletions

File tree

src/Models/InDmKho.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* @copyright © 2019 Dxvn, Inc.
7+
*
8+
* @author Tran Ngoc Duc <ductn@diepxuan.com>
9+
* @author Tran Ngoc Duc <caothu91@gmail.com>
10+
*
11+
* @lastupdate 2025-08-02 21:46:08
12+
*/
13+
14+
namespace Diepxuan\Simba\Models;
15+
16+
use Diepxuan\Simba\SModel\InDmKho as Model;
17+
use Illuminate\Database\Eloquent\Casts\Attribute;
18+
use Illuminate\Support\Collection;
19+
use Illuminate\Support\Facades\DB;
20+
21+
class InDmKho extends Model
22+
{
23+
/**
24+
* Gọi stored procedure asINGetDMKHO để lấy dữ liệu Danh sách kho.
25+
*
26+
* @return array
27+
*/
28+
public static function getAsINGetDMKHO(array $params): Collection
29+
{
30+
// \Debugbar::info($params);
31+
32+
return collect(DB::connection((new static())->getConnectionName())->select(
33+
<<<'EOF'
34+
EXECUTE asINGetDMKHO
35+
@pMa_Cty = :pMa_Cty,
36+
@pMa_kho = :pMa_kho,
37+
@pStruct = :pStruct
38+
EOF
39+
,
40+
[
41+
'pMa_Cty' => $params['pMa_Cty'] ?? '',
42+
'pMa_kho' => $params['pMa_kho'] ?? null,
43+
'pStruct' => $params['pStruct'] ?? null,
44+
]
45+
));
46+
}
47+
48+
protected function id(): Attribute
49+
{
50+
return Attribute::make(
51+
get: static fn (mixed $value, array $attributes) => implode('_', [$attributes['ma_cty'], $attributes['ma_kho']]),
52+
);
53+
}
54+
55+
protected function sku(): Attribute
56+
{
57+
return Attribute::make(
58+
get: static fn (mixed $value, array $attributes) => $attributes['ma_kho'],
59+
);
60+
}
61+
62+
protected function name(): Attribute
63+
{
64+
return Attribute::make(
65+
get: static fn (mixed $value, array $attributes) => $attributes['ten_kho'],
66+
);
67+
}
68+
}

src/Models/InDmNhvt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @author Tran Ngoc Duc <ductn@diepxuan.com>
99
* @author Tran Ngoc Duc <caothu91@gmail.com>
1010
*
11-
* @lastupdate 2025-08-02 20:51:14
11+
* @lastupdate 2025-08-02 21:46:14
1212
*/
1313

1414
namespace Diepxuan\Simba\Models;
@@ -83,7 +83,7 @@ public function scopeHasParent($query, $parent = '')
8383
*/
8484
public static function getAsINGetDMNHVT(array $params): Collection
8585
{
86-
\Debugbar::info($params);
86+
// \Debugbar::info($params);
8787

8888
return collect(DB::connection((new static())->getConnectionName())->select(
8989
<<<'EOF'

src/SModel/InDmKho.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @author Tran Ngoc Duc <ductn@diepxuan.com>
99
* @author Tran Ngoc Duc <caothu91@gmail.com>
1010
*
11-
* @lastupdate 2024-06-14 21:29:56
11+
* @lastupdate 2025-08-02 21:18:25
1212
*/
1313

1414
namespace Diepxuan\Simba\SModel;
@@ -20,8 +20,8 @@ class InDmKho extends SModel
2020
{
2121
use HasCompositePrimaryKey;
2222

23-
public const CREATED_AT = 'cDate';
24-
public const UPDATED_AT = 'lDate';
23+
public const CREATED_AT = 'cdate';
24+
public const UPDATED_AT = 'ldate';
2525

2626
/**
2727
* Indicates if the IDs are auto-incrementing.
@@ -42,7 +42,14 @@ class InDmKho extends SModel
4242
*
4343
* @var string
4444
*/
45-
protected $primaryKey = ['ma_cty', 'ma_vt'];
45+
protected $primaryKey = 'ma_kho';
46+
47+
/**
48+
* The "type" of the primary key ID.
49+
*
50+
* @var string
51+
*/
52+
protected $keyType = 'string';
4653

4754
/**
4855
* The attributes that should be cast.

0 commit comments

Comments
 (0)