diff --git a/app/Http/Resources/InvoiceResource.php b/app/Http/Resources/InvoiceResource.php index c0c83fa5..2856d3d5 100644 --- a/app/Http/Resources/InvoiceResource.php +++ b/app/Http/Resources/InvoiceResource.php @@ -16,32 +16,49 @@ class InvoiceResource extends JsonResource public function toArray($request) { $user = User::where('stripe_id', $this->customer)->first(); - $subscription = $this->subscriptions()[0]; + $invoice_items = []; + $invoice_subscriptions = []; + + // Format bag + foreach ($this->invoiceItems() as $item) { + array_push($invoice_items, [ + 'amount' => $item->total(), + 'description' => $item->description, + 'currency' => $item->currency, + 'type' => $item->type, + ]); + } + + // Format bag + foreach ($this->subscriptions() as $item) { + array_push($invoice_subscriptions, [ + 'amount' => $item->total(), + 'description' => $item->description, + 'currency' => $item->currency, + 'type' => $item->type, + ]); + } return [ 'data' => [ 'id' => $this->id, 'type' => 'invoices', 'attributes' => [ - 'customer' => $this->customer, - 'total' => $this->total(), - 'currency' => $this->currency, - 'created_at_formatted' => format_date($this->date(), '%d. %B. %Y'), - 'created_at' => $this->created, - 'order' => $this->number, - 'user_id' => $user ? $user->id : null, - 'client' => [ + 'customer' => $this->customer, + 'total' => $this->total(), + 'currency' => $this->currency, + 'created_at_formatted' => format_date($this->date(), '%d. %B. %Y'), + 'created_at' => $this->created, + 'order' => $this->number, + 'user_id' => $user ? $user->id : null, + 'client' => [ 'billing_address' => $this->customer_address, 'billing_name' => $this->customer_name, 'billing_phone_number' => $this->customer_phone, ], - 'bag' => [ - 'amount' => $subscription->amount, - 'currency' => $subscription->currency, - 'type' => $subscription->type, - 'description' => $subscription->description, - ], - 'seller' => null, + 'seller' => null, + 'invoice_items' => $invoice_items, + 'invoice_subscriptions' => $invoice_subscriptions, ] ], $this->mergeWhen($user, [ diff --git a/app/Services/StripeService.php b/app/Services/StripeService.php index e2d1876a..c21ea070 100644 --- a/app/Services/StripeService.php +++ b/app/Services/StripeService.php @@ -347,7 +347,7 @@ class StripeService */ public function getUserInvoice($customer, $id) { - $user = User::where('stripe_id', $customer)->first(); + $user = User::where('stripe_id', $customer)->firstOrFail(); return $user->findInvoice($id); } diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 84307b4c..5992b7c4 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,77 @@ { "/js/main.js": "/js/main.js", - "/css/app.css": "/css/app.css" + "/css/app.css": "/css/app.css", + "/js/main.106812bee98d73136ccb.hot-update.js": "/js/main.106812bee98d73136ccb.hot-update.js", + "/js/main.8621138aee2c0a61d67f.hot-update.js": "/js/main.8621138aee2c0a61d67f.hot-update.js", + "/js/main.dd6c335d96ee9985d68f.hot-update.js": "/js/main.dd6c335d96ee9985d68f.hot-update.js", + "/js/main.c8d6fde86a6639aa371a.hot-update.js": "/js/main.c8d6fde86a6639aa371a.hot-update.js", + "/js/main.5562e3d619f26be41add.hot-update.js": "/js/main.5562e3d619f26be41add.hot-update.js", + "/js/main.77742cf2b8f4e0580009.hot-update.js": "/js/main.77742cf2b8f4e0580009.hot-update.js", + "/js/main.70ba5e77c80abf731fd2.hot-update.js": "/js/main.70ba5e77c80abf731fd2.hot-update.js", + "/js/main.b747d3ffd5a8cca43ae4.hot-update.js": "/js/main.b747d3ffd5a8cca43ae4.hot-update.js", + "/js/main.4e1cccd4f2e5efc5a389.hot-update.js": "/js/main.4e1cccd4f2e5efc5a389.hot-update.js", + "/js/main.26c4cf4b90a18022d7a1.hot-update.js": "/js/main.26c4cf4b90a18022d7a1.hot-update.js", + "/js/main.a7937ff14c4c1fa3ef67.hot-update.js": "/js/main.a7937ff14c4c1fa3ef67.hot-update.js", + "/js/main.3cad9e8d624e2a484cdd.hot-update.js": "/js/main.3cad9e8d624e2a484cdd.hot-update.js", + "/js/main.f41928cb829d91d2c566.hot-update.js": "/js/main.f41928cb829d91d2c566.hot-update.js", + "/js/main.d8be6422ce8964879893.hot-update.js": "/js/main.d8be6422ce8964879893.hot-update.js", + "/js/main.a50b5cea82cf38085ff7.hot-update.js": "/js/main.a50b5cea82cf38085ff7.hot-update.js", + "/js/main.96aeefeacdf41380d1a7.hot-update.js": "/js/main.96aeefeacdf41380d1a7.hot-update.js", + "/js/main.216d640d9fe64a6de498.hot-update.js": "/js/main.216d640d9fe64a6de498.hot-update.js", + "/js/main.830b61785301ca4b6b0b.hot-update.js": "/js/main.830b61785301ca4b6b0b.hot-update.js", + "/js/main.7084be65c8385ac02a1d.hot-update.js": "/js/main.7084be65c8385ac02a1d.hot-update.js", + "/js/main.da3f4fa9c6f4feeecd94.hot-update.js": "/js/main.da3f4fa9c6f4feeecd94.hot-update.js", + "/js/main.92de8336d78d28cbdc7e.hot-update.js": "/js/main.92de8336d78d28cbdc7e.hot-update.js", + "/js/main.74223da74f4f33793477.hot-update.js": "/js/main.74223da74f4f33793477.hot-update.js", + "/js/main.a8b0b591686e15342fad.hot-update.js": "/js/main.a8b0b591686e15342fad.hot-update.js", + "/js/main.aa92d5adb1d7c1171547.hot-update.js": "/js/main.aa92d5adb1d7c1171547.hot-update.js", + "/js/main.e4f75bd33ed7e3280082.hot-update.js": "/js/main.e4f75bd33ed7e3280082.hot-update.js", + "/js/main.cde4842646bab538d900.hot-update.js": "/js/main.cde4842646bab538d900.hot-update.js", + "/js/main.1817712990191da4df15.hot-update.js": "/js/main.1817712990191da4df15.hot-update.js", + "/js/main.c03008dba2f79ce1186f.hot-update.js": "/js/main.c03008dba2f79ce1186f.hot-update.js", + "/js/main.e4b0c45602e7e1093b81.hot-update.js": "/js/main.e4b0c45602e7e1093b81.hot-update.js", + "/js/main.915ed88076aab030fdd5.hot-update.js": "/js/main.915ed88076aab030fdd5.hot-update.js", + "/js/main.06a4f68b906dcf488546.hot-update.js": "/js/main.06a4f68b906dcf488546.hot-update.js", + "/js/main.36f2e6e3a1f3d7845c3a.hot-update.js": "/js/main.36f2e6e3a1f3d7845c3a.hot-update.js", + "/js/main.b4bd52a3c21ffb89e2f5.hot-update.js": "/js/main.b4bd52a3c21ffb89e2f5.hot-update.js", + "/js/main.c7face95076eb4b7ce34.hot-update.js": "/js/main.c7face95076eb4b7ce34.hot-update.js", + "/js/main.5d77a5833fb2420e0a4c.hot-update.js": "/js/main.5d77a5833fb2420e0a4c.hot-update.js", + "/js/main.f4b8bc1f12e5c65ae307.hot-update.js": "/js/main.f4b8bc1f12e5c65ae307.hot-update.js", + "/js/main.3738f1a2b60b8567aff4.hot-update.js": "/js/main.3738f1a2b60b8567aff4.hot-update.js", + "/js/main.b0b53080a4fcd75a6f46.hot-update.js": "/js/main.b0b53080a4fcd75a6f46.hot-update.js", + "/js/main.ece949b692a443be4707.hot-update.js": "/js/main.ece949b692a443be4707.hot-update.js", + "/js/main.f15430b33a9487011b08.hot-update.js": "/js/main.f15430b33a9487011b08.hot-update.js", + "/js/main.4f980f3ed0819acd20da.hot-update.js": "/js/main.4f980f3ed0819acd20da.hot-update.js", + "/js/main.bb4445f6b9aca9569559.hot-update.js": "/js/main.bb4445f6b9aca9569559.hot-update.js", + "/js/main.ac4f05e4656406d76c9f.hot-update.js": "/js/main.ac4f05e4656406d76c9f.hot-update.js", + "/js/main.c661c0acfa0152ccab3d.hot-update.js": "/js/main.c661c0acfa0152ccab3d.hot-update.js", + "/js/main.4b4b4c69b53d5b21d355.hot-update.js": "/js/main.4b4b4c69b53d5b21d355.hot-update.js", + "/js/main.6b8abf41e791569d451a.hot-update.js": "/js/main.6b8abf41e791569d451a.hot-update.js", + "/js/main.10008c45dea46c1723df.hot-update.js": "/js/main.10008c45dea46c1723df.hot-update.js", + "/js/main.1a6cd71b8cb6ce854d97.hot-update.js": "/js/main.1a6cd71b8cb6ce854d97.hot-update.js", + "/js/main.62307adf16c2ec7c2cb4.hot-update.js": "/js/main.62307adf16c2ec7c2cb4.hot-update.js", + "/js/main.893170ee8ec98367019d.hot-update.js": "/js/main.893170ee8ec98367019d.hot-update.js", + "/js/main.f2f96922126908ddf594.hot-update.js": "/js/main.f2f96922126908ddf594.hot-update.js", + "/js/main.1fd05d9e7702b1cc7274.hot-update.js": "/js/main.1fd05d9e7702b1cc7274.hot-update.js", + "/js/main.c02979ca7ffc425e3ac8.hot-update.js": "/js/main.c02979ca7ffc425e3ac8.hot-update.js", + "/js/main.ae8714cf20dddc311b79.hot-update.js": "/js/main.ae8714cf20dddc311b79.hot-update.js", + "/js/main.f005250574e90c2da04d.hot-update.js": "/js/main.f005250574e90c2da04d.hot-update.js", + "/js/main.785aa60110fd41ce4459.hot-update.js": "/js/main.785aa60110fd41ce4459.hot-update.js", + "/js/main.99b8f7feea76d5edb1f4.hot-update.js": "/js/main.99b8f7feea76d5edb1f4.hot-update.js", + "/js/main.5df7e7541a7baaabb55e.hot-update.js": "/js/main.5df7e7541a7baaabb55e.hot-update.js", + "/js/main.64fe0a65056db9bf85f5.hot-update.js": "/js/main.64fe0a65056db9bf85f5.hot-update.js", + "/js/main.2b89905a5bf8f751ce09.hot-update.js": "/js/main.2b89905a5bf8f751ce09.hot-update.js", + "/js/main.ebf519d4ac5aadfe1b4d.hot-update.js": "/js/main.ebf519d4ac5aadfe1b4d.hot-update.js", + "/js/main.1a8cf326c27f46c26025.hot-update.js": "/js/main.1a8cf326c27f46c26025.hot-update.js", + "/js/main.9aba9b93afec2adefb51.hot-update.js": "/js/main.9aba9b93afec2adefb51.hot-update.js", + "/js/main.09ce036c9c3fabb9b1b3.hot-update.js": "/js/main.09ce036c9c3fabb9b1b3.hot-update.js", + "/js/main.5695381f6fc0dfad104b.hot-update.js": "/js/main.5695381f6fc0dfad104b.hot-update.js", + "/js/main.3f7dc9dd752a29f357c6.hot-update.js": "/js/main.3f7dc9dd752a29f357c6.hot-update.js", + "/js/main.39b5d5a0ecd3436a3c28.hot-update.js": "/js/main.39b5d5a0ecd3436a3c28.hot-update.js", + "/js/main.303297cf11d6180aeb8c.hot-update.js": "/js/main.303297cf11d6180aeb8c.hot-update.js", + "/js/main.6f40595767f71b28215d.hot-update.js": "/js/main.6f40595767f71b28215d.hot-update.js", + "/js/main.eda0bc6702d559c59bfb.hot-update.js": "/js/main.eda0bc6702d559c59bfb.hot-update.js", + "/js/main.c906a90c3a7db20c1aff.hot-update.js": "/js/main.c906a90c3a7db20c1aff.hot-update.js", + "/js/main.dece824e5460a118f902.hot-update.js": "/js/main.dece824e5460a118f902.hot-update.js", + "/js/main.4d66f2c0cb2ef879ee60.hot-update.js": "/js/main.4d66f2c0cb2ef879ee60.hot-update.js" } diff --git a/resources/js/i18n/lang/en.json b/resources/js/i18n/lang/en.json index 4469ac80..1d515515 100644 --- a/resources/js/i18n/lang/en.json +++ b/resources/js/i18n/lang/en.json @@ -703,9 +703,12 @@ }, "user_payments": { "add_card": "Add Payment Card", + "store_card": "Store Payment Card", "delete_card": "Delete card", "empty": "You don't have any payment cards yet.", "set_as_default": "Set as default card", + "card_field_title": "Credit Card", + "field_loading": "Loading card field...", "title": "Payment Methods" }, "user_settings": { diff --git a/resources/js/views/Admin/Users/UserTabs/UserInvoices.vue b/resources/js/views/Admin/Users/UserTabs/UserInvoices.vue index aafe6273..b7fa7c4d 100644 --- a/resources/js/views/Admin/Users/UserTabs/UserInvoices.vue +++ b/resources/js/views/Admin/Users/UserTabs/UserInvoices.vue @@ -15,8 +15,8 @@
| @lang('vuefilemanager.col_description') | @@ -174,11 +184,21 @@||
| {{ $invoice->subscriptions()[0]->description }} | -{{ $invoice->subscriptions()[0]->type }} | -{{ \Laravel\Cashier\Cashier::formatAmount($invoice->subscriptions()[0]->amount) }} | -
| {{ $item->description }} | +{{ $item->total() }} | +|
| @lang('vuefilemanager.subscription') ({{ $subscription->quantity }}) | +{{ $subscription->startDateAsCarbon()->formatLocalized('%d. %B. %Y') }} - + {{ $subscription->endDateAsCarbon()->formatLocalized('%d. %B. %Y') }} | +{{ $subscription->total() }} | +