Procházet zdrojové kódy

fix: master test-transaction

Muhammad Iqbal Afandi před 3 roky
rodič
revize
d0c27b11bf

+ 16
- 4
app/Http/Controllers/TestTransactionController.php Zobrazit soubor

@@ -12,6 +12,7 @@ use App\Models\Vehicle;
12 12
 use Carbon\Carbon;
13 13
 use Illuminate\Http\Request;
14 14
 use Illuminate\Support\Str;
15
+use Inertia\Inertia;
15 16
 
16 17
 class TestTransactionController extends Controller
17 18
 {
@@ -56,10 +57,21 @@ class TestTransactionController extends Controller
56 57
 
57 58
         $outTransactionCount = OutTransaction::get()->count();
58 59
 
59
-        $typeVehicles = TypeVehicle::get()->transform(fn($typeVehicle) => [
60
-            'value' => $typeVehicle->id,
61
-            'label' => $typeVehicle->type,
62
-        ]);
60
+        $typeVehicles = function () {
61
+            $vehicle = Vehicle::where('plat_number', request('plat_number'))->first();
62
+
63
+            if ($vehicle) {
64
+                return [[
65
+                    'value' => $vehicle->typeVehicle->id,
66
+                    'label' => $vehicle->typeVehicle->type,
67
+                ]];
68
+            } else {
69
+                return TypeVehicle::get()->transform(fn($typeVehicle) => [
70
+                    'value' => $typeVehicle->id,
71
+                    'label' => $typeVehicle->type,
72
+                ]);
73
+            }
74
+        };
63 75
 
64 76
         return inertia('test-transaction/Create.vue', compact([
65 77
             'entryTransactions',

+ 25
- 12
public/js/resources_js_pages_test-transaction_Create_vue.js Zobrazit soubor

@@ -622,11 +622,12 @@ __webpack_require__.r(__webpack_exports__);
622 622
 /* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
623 623
 /* harmony export */ });
624 624
 /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
625
-/* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
626
-/* harmony import */ var _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/components/AppInputText.vue */ "./resources/js/components/AppInputText.vue");
627
-/* harmony import */ var _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/components/AppDropdown.vue */ "./resources/js/components/AppDropdown.vue");
628
-/* harmony import */ var _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/AppPagination.vue */ "./resources/js/components/AppPagination.vue");
629
-/* harmony import */ var _TableHeader__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./TableHeader */ "./resources/js/pages/test-transaction/TableHeader.js");
625
+/* harmony import */ var _inertiajs_inertia__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inertiajs/inertia */ "./node_modules/@inertiajs/inertia/dist/index.js");
626
+/* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
627
+/* harmony import */ var _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/components/AppInputText.vue */ "./resources/js/components/AppInputText.vue");
628
+/* harmony import */ var _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/AppDropdown.vue */ "./resources/js/components/AppDropdown.vue");
629
+/* harmony import */ var _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/components/AppPagination.vue */ "./resources/js/components/AppPagination.vue");
630
+/* harmony import */ var _TableHeader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./TableHeader */ "./resources/js/pages/test-transaction/TableHeader.js");
630 631
 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
631 632
 
632 633
 function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -645,6 +646,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
645 646
 
646 647
 
647 648
 
649
+
648 650
 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
649 651
   props: {
650 652
     data: Object,
@@ -682,12 +684,22 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
682 684
       localEntryTransactions.push.apply(localEntryTransactions, _toConsumableArray(filterLocalEntryTransactions));
683 685
     };
684 686
 
685
-    var form = (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.useForm)({
687
+    var form = (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_2__.useForm)({
686 688
       id: 2,
687 689
       plat_number: null,
688 690
       entry_transaction_id: null,
689 691
       type_vehicle_id: null
690 692
     });
693
+    (0,vue__WEBPACK_IMPORTED_MODULE_0__.watch)(function () {
694
+      return form.plat_number;
695
+    }, function () {
696
+      _inertiajs_inertia__WEBPACK_IMPORTED_MODULE_1__.Inertia.reload({
697
+        only: ['typeVehicles'],
698
+        data: {
699
+          plat_number: form.plat_number
700
+        }
701
+      });
702
+    });
691 703
 
692 704
     var submit = function submit() {
693 705
       form.post(route('test-transactions.store'));
@@ -703,12 +715,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
703 715
       reactive: vue__WEBPACK_IMPORTED_MODULE_0__.reactive,
704 716
       watch: vue__WEBPACK_IMPORTED_MODULE_0__.watch,
705 717
       onMounted: vue__WEBPACK_IMPORTED_MODULE_0__.onMounted,
706
-      useForm: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.useForm,
707
-      AppInputText: _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_2__["default"],
708
-      AppDropdown: _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_3__["default"],
709
-      AppPagination: _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_4__["default"],
710
-      InTable: _TableHeader__WEBPACK_IMPORTED_MODULE_5__.InTable,
711
-      OutTable: _TableHeader__WEBPACK_IMPORTED_MODULE_5__.OutTable
718
+      Inertia: _inertiajs_inertia__WEBPACK_IMPORTED_MODULE_1__.Inertia,
719
+      useForm: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_2__.useForm,
720
+      AppInputText: _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_3__["default"],
721
+      AppDropdown: _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_4__["default"],
722
+      AppPagination: _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_5__["default"],
723
+      InTable: _TableHeader__WEBPACK_IMPORTED_MODULE_6__.InTable,
724
+      OutTable: _TableHeader__WEBPACK_IMPORTED_MODULE_6__.OutTable
712 725
     };
713 726
     Object.defineProperty(__returned__, '__isScriptSetup', {
714 727
       enumerable: false,

+ 25
- 12
public/js/resources_js_pages_test-transaction_Out_vue.js Zobrazit soubor

@@ -202,11 +202,12 @@ __webpack_require__.r(__webpack_exports__);
202 202
 /* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
203 203
 /* harmony export */ });
204 204
 /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
205
-/* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
206
-/* harmony import */ var _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/components/AppInputText.vue */ "./resources/js/components/AppInputText.vue");
207
-/* harmony import */ var _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/components/AppDropdown.vue */ "./resources/js/components/AppDropdown.vue");
208
-/* harmony import */ var _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/AppPagination.vue */ "./resources/js/components/AppPagination.vue");
209
-/* harmony import */ var _TableHeader__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./TableHeader */ "./resources/js/pages/test-transaction/TableHeader.js");
205
+/* harmony import */ var _inertiajs_inertia__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @inertiajs/inertia */ "./node_modules/@inertiajs/inertia/dist/index.js");
206
+/* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
207
+/* harmony import */ var _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/components/AppInputText.vue */ "./resources/js/components/AppInputText.vue");
208
+/* harmony import */ var _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/AppDropdown.vue */ "./resources/js/components/AppDropdown.vue");
209
+/* harmony import */ var _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/components/AppPagination.vue */ "./resources/js/components/AppPagination.vue");
210
+/* harmony import */ var _TableHeader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./TableHeader */ "./resources/js/pages/test-transaction/TableHeader.js");
210 211
 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
211 212
 
212 213
 function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -225,6 +226,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
225 226
 
226 227
 
227 228
 
229
+
228 230
 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
229 231
   props: {
230 232
     data: Object,
@@ -262,12 +264,22 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
262 264
       localEntryTransactions.push.apply(localEntryTransactions, _toConsumableArray(filterLocalEntryTransactions));
263 265
     };
264 266
 
265
-    var form = (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.useForm)({
267
+    var form = (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_2__.useForm)({
266 268
       id: 2,
267 269
       plat_number: null,
268 270
       entry_transaction_id: null,
269 271
       type_vehicle_id: null
270 272
     });
273
+    (0,vue__WEBPACK_IMPORTED_MODULE_0__.watch)(function () {
274
+      return form.plat_number;
275
+    }, function () {
276
+      _inertiajs_inertia__WEBPACK_IMPORTED_MODULE_1__.Inertia.reload({
277
+        only: ['typeVehicles'],
278
+        data: {
279
+          plat_number: form.plat_number
280
+        }
281
+      });
282
+    });
271 283
 
272 284
     var submit = function submit() {
273 285
       form.post(route('test-transactions.store'));
@@ -283,12 +295,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
283 295
       reactive: vue__WEBPACK_IMPORTED_MODULE_0__.reactive,
284 296
       watch: vue__WEBPACK_IMPORTED_MODULE_0__.watch,
285 297
       onMounted: vue__WEBPACK_IMPORTED_MODULE_0__.onMounted,
286
-      useForm: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_1__.useForm,
287
-      AppInputText: _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_2__["default"],
288
-      AppDropdown: _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_3__["default"],
289
-      AppPagination: _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_4__["default"],
290
-      InTable: _TableHeader__WEBPACK_IMPORTED_MODULE_5__.InTable,
291
-      OutTable: _TableHeader__WEBPACK_IMPORTED_MODULE_5__.OutTable
298
+      Inertia: _inertiajs_inertia__WEBPACK_IMPORTED_MODULE_1__.Inertia,
299
+      useForm: _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_2__.useForm,
300
+      AppInputText: _components_AppInputText_vue__WEBPACK_IMPORTED_MODULE_3__["default"],
301
+      AppDropdown: _components_AppDropdown_vue__WEBPACK_IMPORTED_MODULE_4__["default"],
302
+      AppPagination: _components_AppPagination_vue__WEBPACK_IMPORTED_MODULE_5__["default"],
303
+      InTable: _TableHeader__WEBPACK_IMPORTED_MODULE_6__.InTable,
304
+      OutTable: _TableHeader__WEBPACK_IMPORTED_MODULE_6__.OutTable
292 305
     };
293 306
     Object.defineProperty(__returned__, '__isScriptSetup', {
294 307
       enumerable: false,

+ 8
- 0
resources/js/pages/test-transaction/Out.vue Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 <script setup>
2 2
 import { reactive, watch, onMounted } from 'vue'
3
+import { Inertia } from '@inertiajs/inertia'
3 4
 import { useForm } from '@inertiajs/inertia-vue3'
4 5
 import AppInputText from '@/components/AppInputText.vue'
5 6
 import AppDropdown from '@/components/AppDropdown.vue'
@@ -53,6 +54,13 @@ const form = useForm({
53 54
   type_vehicle_id: null,
54 55
 })
55 56
 
57
+watch(
58
+  () => form.plat_number,
59
+  () => {
60
+    Inertia.reload({ only: ['typeVehicles'], data: { plat_number: form.plat_number } })
61
+  }
62
+)
63
+
56 64
 const submit = () => {
57 65
   form.post(route('test-transactions.store'))
58 66
 }