]> _ Git - pmi.git/commitdiff
wait #6519 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 27 Nov 2023 16:15:30 +0000 (17:15 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 27 Nov 2023 16:15:30 +0000 (17:15 +0100)
app/Http/Controllers/AjaxController.php
resources/js/app.js

index 1d9f1cc416cc84a2ac2c38377483b52f43ebc612..6de69cd515c21e821fcc31e63a773f771a306bef 100644 (file)
@@ -671,7 +671,7 @@ class AjaxController extends CubistFrontController
         return $addressToString;
     }
 
-    public function getuser()
+    public function getuser(Request $request)
     {
         $user = Client::getClientConnected();
         if ($user) {
@@ -703,10 +703,15 @@ class AjaxController extends CubistFrontController
         ];
         $data = $this->validation_form($request, $validation);
 
+
         $lastCartId = $request->session()->get('last_selection');
 
         //
-        $lastCartRefs = $lastCartId ? Cart::find($lastCartId)->getReferences() : [];
+        if ($lastCartId && Cart::find($lastCartId)) {
+            $lastCartRefs = $lastCartId ? Cart::find($lastCartId)->getReferences() : [];
+        } else {
+            $lastCartRefs = [];
+        }
         $currentCartRef = Cart::getRefs($data['products']);
         $intersect = $lastCartRefs ? array_intersect($currentCartRef, $lastCartRefs) : [];
 
@@ -721,6 +726,12 @@ class AjaxController extends CubistFrontController
          */
         $data = Cart::fillData($currentCartRef, $data, $productsInfosBase, false);
 
+
+        $auth = auth('web-clients');
+        if (!$auth->guest()) {
+            $data['user_id'] = $auth->user()->id;
+        }
+
         if (sizeof($lastCartRefs) !== sizeof($intersect) ||
             (sizeof($lastCartRefs) === sizeof($intersect) && sizeof($currentCartRef) != sizeof($lastCartRefs))) {
             $data["name"] = __("Panier du :date", ["date" => Carbon::now('Europe/Paris')->isoFormat("DD/MM/Y")]);
index 8bc1322048ad37ebef209987880fc38221484dde..b40e350588dff03219e809c8ff768eac768cb962 100644 (file)
@@ -385,7 +385,7 @@ const app = new Vue({
         getUser() {
             let root = this
 
-            axios.post('/ajax/getuser')
+            axios.get('/ajax/getuser')
                 .then(function (response) {
                     root.user = response.data['user']
                     root.addresses = JSON.parse(root.user.address)