Explorar o código

EVERYTHING WORKING - Safing

WBLKLeipe %!s(int64=3) %!d(string=hai) anos
pai
achega
93d8dfcf0b

+ 5 - 1
app/Http/Controllers/Admin/PaymentController.php

@@ -197,6 +197,9 @@ class PaymentController extends Controller
                     'status' => $response->result->status,
                     'amount' => $paypalProduct->quantity,
                     'price' => $paypalProduct->price,
+                    'tax_value' => $this->getTaxValue($paypalProduct),
+                    'tax_percent' => $this->getTaxPercent(),
+                    'total_price' => $this->getTotalPrice($paypalProduct),
                     'currency_code' => $paypalProduct->currency_code,
                     'payer' => json_encode($response->result->payer),
                 ]);
@@ -235,7 +238,7 @@ class PaymentController extends Controller
      */
     public function cancel(Request $request)
     {
-        return redirect()->route('store.index')->with('success', 'Payment was Cannceled');
+        return redirect()->route('store.index')->with('success', 'Payment was Canceled');
     }
 
 
@@ -254,6 +257,7 @@ class PaymentController extends Controller
             ->editColumn('price', function (Payment $payment) {
                 return $payment->formatCurrency();
             })
+
             ->editColumn('created_at', function (Payment $payment) {
                 return $payment->created_at ? $payment->created_at->diffForHumans() : '';
             })

+ 3 - 0
app/Models/Payment.php

@@ -29,6 +29,9 @@ class Payment extends Model
         'type',
         'amount',
         'price',
+        'tax_value',
+        'total_price',
+        'tax_percent',
         'currency_code',
     ];
 

+ 36 - 0
database/migrations/2021_11_05_071456_add_tax_to_paymentlogs.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddTaxToPaymentlogs extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('payments', function (Blueprint $table) {
+            $table->decimal('tax_value',8,2)->after('price')->nullable();
+            $table->integer('tax_percent')->after('tax_value')->nullable();
+            $table->decimal('total_price',8,2)->after('tax_percent')->nullable();    
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('payments', function (Blueprint $table) {
+            $table->dropColumn('tax_value');
+            $table->dropColumn('tax_percent');
+            $table->dropColumn('total_price');
+        });
+    }
+}

+ 7 - 1
resources/views/admin/payments/index.blade.php

@@ -37,7 +37,10 @@
                             <th>User</th>
                             <th>Type</th>
                             <th>Amount</th>
-                            <th>Price</th>
+                            <th>Product Price</th>
+                            <th>Tax</th>
+                            <th>Tax(%)</th>
+                            <th>Total Price</th>
                             <th>Payment_ID</th>
                             <th>Payer_ID</th>
                             <th>Created at</th>
@@ -68,6 +71,9 @@
                     {data: 'type'},
                     {data: 'amount'},
                     {data: 'price'},
+                    {data: 'tax_value'},
+                    {data: 'tax_percent'},
+                    {data: 'total_price'},
                     {data: 'payment_id'},
                     {data: 'payer_id'},
                     {data: 'created_at'},