]> _ Git - pmi.git/commitdiff
done #6071 @0:05
authorsoufiane <soufiane@cubedesigners.com>
Mon, 3 Jul 2023 09:00:03 +0000 (11:00 +0200)
committersoufiane <soufiane@cubedesigners.com>
Mon, 3 Jul 2023 09:00:03 +0000 (11:00 +0200)
app/Http/Controllers/Admin/ProductBaseController.php
app/Http/Controllers/AjaxController.php
app/Models/Product.php
resources/views/pages/product-detail.blade.php

index 60ce35e784f80f9e9e819fa9037bca1dd4b6c9a2..e6d15fc6ebc099bfce0fc0358e83634ef9e77609 100644 (file)
@@ -85,8 +85,6 @@ class ProductBaseController extends CubistMagicController {
 
                                     if (in_array($field, ["basic_selling_price", "basic_purschase_price", "conversion"])) {
                                         $value = floatval($value);
-                                    } elseif ($field === "currency") {
-                                        $value = substr($value, 0, 1);
                                     } elseif ($field === "discount") {
                                         $value = floatval(str_replace("%", "", $value));
                                     }
index 4bcc69f27ba06196d4e286a66a56a184742f52a3..172c3d80d28e832580cce188a8b07b120ec91895 100644 (file)
@@ -341,7 +341,6 @@ class AjaxController extends CubistFrontController
             throw new ValidationException($validator);
         }
 
-
         $validator->validate();
         return $validator->validated();
     }
@@ -351,9 +350,7 @@ class AjaxController extends CubistFrontController
             'email' => 'required|email'
         ];
         $this->validation_form($request, $validation);
-
-        $email = Client::where('email', $request->email)->get();
-        return $email;
+        return Client::where('email', $request->email)->get();
     }
 
     public function signin(Request $request) {
@@ -369,11 +366,10 @@ class AjaxController extends CubistFrontController
             throw ValidationException::withMessages(['email' => __('Le compte lié à cette adresse est en cours de validation')]);
         }
 
-        $remember = $request->remember_me ? true : false;
+        $remember = (bool)$request->remember_me;
 
         if (Auth::guard('web-clients')->attempt($data, $remember)) {
             $request->session()->regenerate();
-
             return json_encode(['success']);
         } else {
             throw ValidationException::withMessages(['password' => __('Votre e-mail ou mot de passe ne correspondent à aucun compte existant')]);
@@ -434,18 +430,6 @@ class AjaxController extends CubistFrontController
         return $data;
     }
 
-    public function forgotPassword(Request $request) {
-        $request->validate(['email' => 'required|email']);
-
-        $status = Password::sendResetLink(
-            $request->only('email')
-        );
-
-        return $status === Password::RESET_LINK_SENT
-            ? back()->with(['status' => __($status)])
-            : back()->withErrors(['email' => __($status)]);
-    }
-
     public function update(Request $request) {
         $validation = [];
         foreach ($request->all() as $key => $field){
@@ -573,13 +557,11 @@ class AjaxController extends CubistFrontController
                 return $n['delivery_address'];
             });
 
-            $data = [
+            return [
                 'user' => $user,
                 'address_billing' => key($checkBillingAddress) ?? "0",
                 'address_delivery' => key($checkDeliveryAddress) ?? "0"
             ];
-
-            return $data;
         }else{
             abort(401, 'Unauthorized');
         }
@@ -621,7 +603,6 @@ class AjaxController extends CubistFrontController
             $id = $panier->getOriginal('id');
             $request->session()->put('last_selection', $id);
         } else {
-
             Cart::where('id', $lastCartId)->update($data);
         }
 
@@ -662,12 +643,11 @@ class AjaxController extends CubistFrontController
         $cart = Cart::find($cartId)->toArray();
         $ids = Product::getProductIds($cart);
         $productsInfosBase = Product::getProductsByIds($ids);
-
         $clientIdInRequest = intval($cart['user_id']);
+        $cart['products'] = json_decode($cart['products'], true);
+
         $clientId = Client::getClientConnected()->id;
         $currentCartRef = Cart::getRefs(json_decode($cart['products'],true));
-
-        $cart['products'] = json_decode($cart['products'], true);
         $data = Cart::updateCartData($currentCartRef,$cart,$productsInfosBase);
 
         if($clientIdInRequest === $clientId) {
@@ -696,7 +676,6 @@ class AjaxController extends CubistFrontController
         $data['products'] = json_encode($data['products']);
         $ids = Product::getProductIds($data);
         $data['products'] = json_decode($data['products'], true);
-
         $productsInfosBase = Product::getProductsByIds($ids);
         $currentCartRef = Cart::getRefs($data['products']);
 
index 66f54b2be64551bd7fdc9cea4e227fcefa625063..09041f311042eaf88b53cc8ceafffd5542e195a4 100644 (file)
@@ -11,7 +11,6 @@ use Illuminate\Support\Facades\App;
 use Illuminate\Support\Str;
 use Spatie\Image\Manipulations;
 use Spatie\MediaLibrary\Models\Media;
-use Illuminate\Support\Arr;
 
 class Product extends CubistMagicPageModel
 {
@@ -503,7 +502,13 @@ class Product extends CubistMagicPageModel
         return self::$_cart_data;
     }
 
-    public static function getProductsByIds($ids) {
+    public function isJson($string) {
+        json_decode($string);
+        return json_last_error() === JSON_ERROR_NONE;
+    }
+
+    public static function getProductsByIds($ids)
+    {
         return self::whereIn('id', $ids)
             ->select('id','basic_selling_price','category','json')
             ->get()
@@ -511,7 +516,8 @@ class Product extends CubistMagicPageModel
             ->toArray();
     }
 
-    public static function getProductIds($data) {
+    public static function getProductIds($data)
+    {
         if(isset($data['products'])){ //way to check if is multidimensional array
             $allProducts = json_decode($data['products'], true);
             $ids = array_column($allProducts, 'id');
index 5eda7096350dd231e8185262e467f7fafaf26732..2f63521d3a9d90f8484940d6165fbcb1a7a6795b 100644 (file)
                             <div class="opt-configurator bg-grey-200 p-12 mb-8">
                                 <div class="opt-group">
                                     @foreach($specs as $spec)
+                                        @php
+                                            $containEmptyOption = array_filter($spec['options'], function($n) {
+                                                return empty($n['name_fr']);
+                                            });
+                                        @endphp
+                                        @if(sizeof($containEmptyOption) < 1 )
                                         <div class="opt-group">
                                             <label class="opt-name mb-2 inline-block">
                                                 {{  \Illuminate\Support\Str::ucfirst( $spec['name_fr']) }}
@@ -82,6 +88,7 @@
                                                 </select>
                                             </div>
                                         </div>
+                                        @endif
                                     @endforeach
                                 </div>
                             </div>