浏览代码

fix: sales list master

父节点
当前提交
4f99e4bc98

+ 2
- 2
app/Http/Controllers/SalesController.php 查看文件

@@ -37,8 +37,8 @@ class SalesController extends Controller
37 37
                     'price' => $sale->saleDetail->price,
38 38
                     'ppn' => $sale->saleDetail->ppn,
39 39
                     'qty' => $sale->saleDetail->qty,
40
-                    'productName' => $sale->saleDetailProduct,
41
-                    'productNumber' => $sale->saleDetailProduct
40
+                    'productName' => $sale->product->name,
41
+                    'productNumber' => $sale->product->number
42 42
                 ])
43 43
         ]);
44 44
     }

+ 18
- 2
app/Models/Sale.php 查看文件

@@ -2,6 +2,8 @@
2 2
 
3 3
 namespace App\Models;
4 4
 
5
+use Carbon\Carbon;
6
+use Illuminate\Database\Eloquent\Casts\Attribute;
5 7
 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 8
 use Illuminate\Database\Eloquent\Model;
7 9
 
@@ -16,14 +18,28 @@ class Sale extends Model
16 18
         'user_id'
17 19
     ];
18 20
 
21
+    protected function updatedAt(): Attribute
22
+    {
23
+        return Attribute::make(
24
+            get:fn($value) => Carbon::parse($value)->translatedFormat('l d/m/Y H:i:s')
25
+        );
26
+    }
27
+
19 28
     public function saleDetail()
20 29
     {
21 30
         return $this->hasOne(SaleDetail::class);
22 31
     }
23 32
 
24
-    public function saleDetailProduct()
33
+    public function product()
25 34
     {
26
-        return $this->belongsToMany(Product::class, SaleDetail::class);
35
+        return $this->hasOneThrough(
36
+            Product::class,
37
+            SaleDetail::class,
38
+            'sale_id',
39
+            'number',
40
+            'id',
41
+            'product_id'
42
+        );
27 43
     }
28 44
 
29 45
     public function scopeFilter($query, array $filters)

+ 5
- 5
designs/diagrams/database.puml 查看文件

@@ -71,7 +71,7 @@ entity StockProduct {
71 71
   * sale_number
72 72
   * amount
73 73
   __
74
-  * product_id
74
+  * product_number
75 75
 }
76 76
 
77 77
 entity Price {
@@ -79,7 +79,7 @@ entity Price {
79 79
   __
80 80
   * price
81 81
   __
82
-  * product_id
82
+  * product_number
83 83
   * customer_id
84 84
   * supplier_id
85 85
 }
@@ -92,7 +92,7 @@ entity SaleDetail {
92 92
   * qty
93 93
   __
94 94
   * sale_id
95
-  * product_id
95
+  * product_number
96 96
 }
97 97
 
98 98
 entity PurchaseDetail {
@@ -102,8 +102,8 @@ entity PurchaseDetail {
102 102
   * ppn
103 103
   * qty
104 104
   __
105
-  * purchase_id
106
-  * product_id
105
+  * purchase_number
106
+  * product_number
107 107
 }
108 108
 
109 109
 User ||--|{ Role

+ 2
- 5
public/js/resources_js_pages_Users_Index_vue.js 查看文件

@@ -1097,13 +1097,10 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
1097 1097
             "class": "w-full md:w-27rem",
1098 1098
             placeholder: "cari, contoh: tina",
1099 1099
             url: "/users",
1100
-            modelValue: _ctx.search,
1101
-            "onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) {
1102
-              return _ctx.search = $event;
1103
-            })
1100
+            initialSearch: $props.initialSearch
1104 1101
           }, null, 8
1105 1102
           /* PROPS */
1106
-          , ["modelValue"])])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_5, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["AppButtonLink"], {
1103
+          , ["initialSearch"])])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_5, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup["AppButtonLink"], {
1107 1104
             label: "Tambah User",
1108 1105
             icon: "pi pi-pencil",
1109 1106
             "class": "p-button-outlined",

+ 1
- 1
public/js/vue.js 查看文件

@@ -58836,7 +58836,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.21.4","description":"P
58836 58836
 /******/ 		// This function allow to reference async chunks
58837 58837
 /******/ 		__webpack_require__.u = (chunkId) => {
58838 58838
 /******/ 			// return url for filenames based on template
58839
-/******/ 			return "js/" + chunkId + ".js?id=" + {"node_modules_chart_js_auto_auto_esm_js":"9296b829a7757dee","resources_js_pages_Auth_Login_vue":"be578e085a239e29","resources_js_pages_Customers_Create_vue":"3f071508eabc668b","resources_js_pages_Customers_Edit_vue":"aebd0864e4ad3e68","resources_js_pages_Customers_Index_vue":"1e494ee438fa9df6","resources_js_pages_Customers_config_js":"3e69b9c9add806c6","resources_js_pages_Dashboards_Index_vue":"d3d4e8305b123375","resources_js_pages_Error_Index_vue":"4119ff1c60260652","resources_js_pages_Products_Create_vue":"654f3597a7f836a8","resources_js_pages_Products_Edit_vue":"92630d22ca001222","resources_js_pages_Products_Index_vue":"f21347c772e5a78b","resources_js_pages_Products_config_js":"885a5522b0477687","resources_js_pages_Purchases_Index_vue":"b4137df9a769fdf3","resources_js_pages_Sales_Components_Dialog_CustomerCreate_vue":"0e45b005d2175423","resources_js_pages_Sales_Components_Dialog_ProductCreate_vue":"26ef1d3355ba7e47","resources_js_pages_Sales_Components_SaleDetails_vue":"b0aacea6649cd1d1","resources_js_pages_Sales_Create_vue":"e90f4bf66d9a6f95","resources_js_pages_Sales_Index_vue":"ea504c94494d14bb","resources_js_pages_Sales_config_js":"130f88fd092690ee","resources_js_pages_StockProducts_Index_vue":"7f6b33a4fbab582d","resources_js_pages_Suppliers_Create_vue":"c013262c0e5fb7ee","resources_js_pages_Suppliers_Edit_vue":"c026816d9eff6a88","resources_js_pages_Suppliers_Index_vue":"96c102e92f653886","resources_js_pages_Suppliers_config_js":"52e8d25c6bfab54b","resources_js_pages_Users_Create_vue":"efad98f9f2b8dba6","resources_js_pages_Users_Edit_vue":"a5c8a2cdddf14020","resources_js_pages_Users_Index_vue":"12226586ae7d59c0","resources_js_pages_Users_Show_vue":"1e641b8d61834507","resources_js_pages_Users_config_js":"92384d78612abc88"}[chunkId] + "";
58839
+/******/ 			return "js/" + chunkId + ".js?id=" + {"node_modules_chart_js_auto_auto_esm_js":"9296b829a7757dee","resources_js_pages_Auth_Login_vue":"be578e085a239e29","resources_js_pages_Customers_Create_vue":"3f071508eabc668b","resources_js_pages_Customers_Edit_vue":"aebd0864e4ad3e68","resources_js_pages_Customers_Index_vue":"1e494ee438fa9df6","resources_js_pages_Customers_config_js":"3e69b9c9add806c6","resources_js_pages_Dashboards_Index_vue":"d3d4e8305b123375","resources_js_pages_Error_Index_vue":"4119ff1c60260652","resources_js_pages_Products_Create_vue":"654f3597a7f836a8","resources_js_pages_Products_Edit_vue":"92630d22ca001222","resources_js_pages_Products_Index_vue":"f21347c772e5a78b","resources_js_pages_Products_config_js":"885a5522b0477687","resources_js_pages_Purchases_Index_vue":"b4137df9a769fdf3","resources_js_pages_Sales_Components_Dialog_CustomerCreate_vue":"0e45b005d2175423","resources_js_pages_Sales_Components_Dialog_ProductCreate_vue":"26ef1d3355ba7e47","resources_js_pages_Sales_Components_SaleDetails_vue":"b0aacea6649cd1d1","resources_js_pages_Sales_Create_vue":"e90f4bf66d9a6f95","resources_js_pages_Sales_Index_vue":"ea504c94494d14bb","resources_js_pages_Sales_config_js":"130f88fd092690ee","resources_js_pages_StockProducts_Index_vue":"7f6b33a4fbab582d","resources_js_pages_Suppliers_Create_vue":"c013262c0e5fb7ee","resources_js_pages_Suppliers_Edit_vue":"c026816d9eff6a88","resources_js_pages_Suppliers_Index_vue":"96c102e92f653886","resources_js_pages_Suppliers_config_js":"52e8d25c6bfab54b","resources_js_pages_Users_Create_vue":"efad98f9f2b8dba6","resources_js_pages_Users_Edit_vue":"a5c8a2cdddf14020","resources_js_pages_Users_Index_vue":"bcd25543a8cc6f19","resources_js_pages_Users_Show_vue":"1e641b8d61834507","resources_js_pages_Users_config_js":"92384d78612abc88"}[chunkId] + "";
58840 58840
 /******/ 		};
58841 58841
 /******/ 	})();
58842 58842
 /******/ 	

+ 1
- 1
resources/js/pages/Users/Index.vue 查看文件

@@ -51,7 +51,7 @@ const onResetPassword = (data) => {
51 51
                 class="w-full md:w-27rem"
52 52
                 placeholder="cari, contoh: tina"
53 53
                 url="/users"
54
-                v-model="search"
54
+                :initialSearch="initialSearch"
55 55
               />
56 56
             </div>
57 57
           </div>