Bläddra i källkod

Fixing FormatCurrency

WBLKLeipe 3 år sedan
förälder
incheckning
3f67ac5f21

+ 7 - 2
app/Http/Controllers/Admin/PaymentController.php

@@ -255,9 +255,14 @@ class PaymentController extends Controller
                 return $payment->user->name;
             })
             ->editColumn('price', function (Payment $payment) {
-                return $payment->formatCurrency();
+                return $payment->formatToCurrency($payment->price);
+            })
+            ->editColumn('tax_value', function (Payment $payment) {
+                return $payment->formatToCurrency($payment->tax_value);
+            })
+            ->editColumn('total_price', function (Payment $payment) {
+                return $payment->formatToCurrency($payment->total_price);
             })
-
             ->editColumn('created_at', function (Payment $payment) {
                 return $payment->created_at ? $payment->created_at->diffForHumans() : '';
             })

+ 2 - 3
app/Models/Payment.php

@@ -53,10 +53,9 @@ class Payment extends Model
     {
         return $this->belongsTo(User::class);
     }
-
-    public function formatCurrency($locale = 'en_US')
+    public function formatToCurrency($value,$locale = 'de_DE')
     {
         $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
-        return $formatter->formatCurrency($this->price, $this->currency_code);
+        return $formatter->formatCurrency($value, $this->currency_code);
     }
 }

+ 2 - 2
app/Models/PaypalProduct.php

@@ -43,9 +43,9 @@ class PaypalProduct extends Model
      * @param string $locale
      * @return string
      */
-    public function formatCurrency($locale = 'en_US')
+    public function formatToCurrency($value,$locale = 'de_DE')
     {
         $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
-        return $formatter->formatCurrency($this->price, $this->currency_code);
+        return $formatter->formatCurrency($value, $this->currency_code);
     }
 }

+ 4 - 4
resources/views/store/checkout.blade.php

@@ -83,7 +83,7 @@
                                         <td>1</td>
                                         <td><i class="fa fa-coins mr-2"></i>{{$product->quantity}} {{strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type}}</td>
                                         <td>{{$product->description}}</td>
-                                        <td>{{$product->formatCurrency()}}</td>
+                                        <td>{{$product->formatToCurrency($product->price)}}</td>
                                     </tr>
                                     </tbody>
                                 </table>
@@ -111,11 +111,11 @@
                                     <table class="table">
                                         <tr>
                                             <th style="width:50%">Subtotal:</th>
-                                            <td>{{$product->formatCurrency()}}</td>
+                                            <td>{{$product->formatToCurrency($product->price)}}</td>
                                         </tr>
                                         <tr>
                                             <th>Tax ({{$taxpercent}}%)</th>
-                                            <td>€{{number_format($taxvalue, 2, '.', '')}}</td>
+                                            <td>{{$product->formatToCurrency($taxvalue)}}</td>
                                         </tr>
                                         <tr>
                                             <th>Quantity:</th>
@@ -123,7 +123,7 @@
                                         </tr>
                                         <tr>
                                             <th>Total:</th>
-                                            <td>€{{number_format($total, 2, '.', '')}}</td>
+                                            <td>{{$product->formatToCurrency($total)}}</td>
                                         </tr>
                                     </table>
                                 </div>