diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index cbed821c..aac2cc4a 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -18,16 +18,16 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Storage; +use LaravelDaily\Invoices\Classes\Buyer; +use LaravelDaily\Invoices\Classes\InvoiceItem; use LaravelDaily\Invoices\Classes\Party; +use LaravelDaily\Invoices\Invoice; use PayPalCheckoutSdk\Core\PayPalHttpClient; use PayPalCheckoutSdk\Core\ProductionEnvironment; use PayPalCheckoutSdk\Core\SandboxEnvironment; use PayPalCheckoutSdk\Orders\OrdersCaptureRequest; use PayPalCheckoutSdk\Orders\OrdersCreateRequest; use PayPalHttp\HttpException; -use LaravelDaily\Invoices\Invoice; -use LaravelDaily\Invoices\Classes\Buyer; -use LaravelDaily\Invoices\Classes\InvoiceItem; class PaymentController extends Controller { @@ -50,10 +50,10 @@ class PaymentController extends Controller public function checkOut(Request $request, PaypalProduct $paypalProduct) { return view('store.checkout')->with([ - 'product' => $paypalProduct, - 'taxvalue' => $paypalProduct->getTaxValue(), - 'taxpercent' => $paypalProduct->getTaxPercent(), - 'total' => $paypalProduct->getTotalPrice() + 'product' => $paypalProduct, + 'taxvalue' => $paypalProduct->getTaxValue(), + 'taxpercent' => $paypalProduct->getTaxPercent(), + 'total' => $paypalProduct->getTotalPrice() ]); } @@ -72,12 +72,12 @@ class PaymentController extends Controller [ "reference_id" => uniqid(), "description" => $paypalProduct->description, - "amount" => [ - "value" => $paypalProduct->getTotalPrice(), + "amount" => [ + "value" => $paypalProduct->getTotalPrice(), 'currency_code' => strtoupper($paypalProduct->currency_code), - 'breakdown' =>[ + 'breakdown' => [ 'item_total' => - [ + [ 'currency_code' => strtoupper($paypalProduct->currency_code), 'value' => $paypalProduct->price, ], @@ -93,8 +93,8 @@ class PaymentController extends Controller "application_context" => [ "cancel_url" => route('payment.cancel'), "return_url" => route('payment.success', ['product' => $paypalProduct->id]), - 'brand_name' => config('app.name', 'Laravel'), - 'shipping_preference' => 'NO_SHIPPING' + 'brand_name' => config('app.name', 'Laravel'), + 'shipping_preference' => 'NO_SHIPPING' ] @@ -194,25 +194,23 @@ class PaymentController extends Controller event(new UserUpdateCreditsEvent($user)); //create invoice - $lastInvoiceID = \App\Models\invoice::where("invoice_name","like","%".now()->format('mY')."%")->max("id"); + $lastInvoiceID = \App\Models\invoice::where("invoice_name", "like", "%" . now()->format('mY') . "%")->max("id"); $newInvoiceID = $lastInvoiceID + 1; $seller = new Party([ - 'name' => env("APP_NAME", "Controlpanel.gg"), - 'phone' => env("COMPANY_PHONE",""), - 'address' => env("COMPANY_ADRESS",""), - 'vat' => env("COMPANY_VAT_ID",""), + 'name' => env("APP_NAME", "Controlpanel.gg"), + 'phone' => env("COMPANY_PHONE", ""), + 'address' => env("COMPANY_ADRESS", ""), + 'vat' => env("COMPANY_VAT_ID", ""), 'custom_fields' => [ 'E-Mail' => env("MAIL_FROM_ADDRESS", "company@mail.com"), - "Web" => env("APP_URL","https://controlpanel.gg") + "Web" => env("APP_URL", "https://controlpanel.gg") ], ]); - - $customer = new Buyer([ - 'name' => $user->name, + 'name' => $user->name, 'custom_fields' => [ 'E-Mail' => $user->email, 'Client ID' => $user->id, @@ -228,17 +226,16 @@ class PaymentController extends Controller ->shipping(0) ->addItem($item) ->status(__('invoices::invoice.paid')) - ->series(now()->format('mY')) ->delimiter("-") ->sequence($newInvoiceID) - ->serialNumberFormat(env("INVOICE_PREFIX","INV").'{DELIMITER}{SERIES}{SEQUENCE}') + ->serialNumberFormat(env("INVOICE_PREFIX", "INV") . '{DELIMITER}{SERIES}{SEQUENCE}') ->logo(public_path('vendor/invoices/logo.png')); //Save the invoice in "storage\app\invoice\USER_ID\YEAR" - $invoice->filename=$invoice->getSerialNumber().'.pdf'; + $invoice->filename = $invoice->getSerialNumber() . '.pdf'; $invoice->render(); - Storage::disk("local")->put("invoice/".$user->id."/".now()->format('Y')."/".$invoice->filename, $invoice->output); + Storage::disk("local")->put("invoice/" . $user->id . "/" . now()->format('Y') . "/" . $invoice->filename, $invoice->output); \App\Models\invoice::create([ @@ -248,7 +245,7 @@ class PaymentController extends Controller ]); //Send Invoice per Mail - $user->notify(new InvoiceNotification($invoice,$user, $payment)); + $user->notify(new InvoiceNotification($invoice, $user, $payment)); //redirect back to home return redirect()->route('home')->with('success', 'Your credit balance has been increased!'); diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 375c5c0c..5292ba4b 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -39,4 +39,15 @@ class SettingsController extends Controller return redirect()->route('admin.settings.index')->with('success', 'Icons updated!'); } + public function updateInvoiceSettings(Request $request) + { + $request->validate([ + 'icon' => 'nullable', + 'favicon' => 'nullable', + ]); + + + return redirect()->route('admin.settings.index')->with('success', 'Invoice settings updated!'); + } + } diff --git a/app/Notifications/InvoiceNotification.php b/app/Notifications/InvoiceNotification.php index c905c26a..78408ae2 100644 --- a/app/Notifications/InvoiceNotification.php +++ b/app/Notifications/InvoiceNotification.php @@ -2,17 +2,18 @@ namespace App\Notifications; +use App\Models\Payment; use App\Models\User; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -use App\Models\Payment; use LaravelDaily\Invoices\Invoice; class InvoiceNotification extends Notification { use Queueable; + /** * @var invoice * * @var invoice @@ -57,12 +58,12 @@ class InvoiceNotification extends Notification ->subject('Your Payment was successful!') ->greeting('Hello,') ->line("Your payment was processes!.") - ->line('Status: '.$this->payment->status) - ->line('Price: '.$this->payment->formatToCurrency($this->payment->total_price)) - ->line('Type: '.$this->payment->type) - ->line('Amount: '.$this->payment->amount) - ->line('Balance: '.$this->user->credits) - ->line('User ID: '.$this->payment->user_id) - ->attach(storage_path('app/invoice/'.$this->user->id.'/'.now()->format('Y').'/'.$this->invoice->filename)); + ->line('Status: ' . $this->payment->status) + ->line('Price: ' . $this->payment->formatToCurrency($this->payment->total_price)) + ->line('Type: ' . $this->payment->type) + ->line('Amount: ' . $this->payment->amount) + ->line('Balance: ' . $this->user->credits) + ->line('User ID: ' . $this->payment->user_id) + ->attach(storage_path('app/invoice/' . $this->user->id . '/' . now()->format('Y') . '/' . $this->invoice->filename)); } } diff --git a/resources/views/admin/settings/index.blade.php b/resources/views/admin/settings/index.blade.php index 55a0150f..683d9e95 100644 --- a/resources/views/admin/settings/index.blade.php +++ b/resources/views/admin/settings/index.blade.php @@ -39,6 +39,9 @@ + @@ -88,14 +91,116 @@ chrome hotkey) to reload without cache to see your changes appear :)

- +
+
+ @csrf + @method('PATCH') + +
+
+ +
+
+ + +
+ @error('company-phone') + + {{$message}} + + @enderror +
+ +
+
+ + +
+ @error('company-name') + + {{$message}} + + @enderror +
+ +
+
+ + +
+ @error('company-vat') + + {{$message}} + + @enderror +
+ + +
+
+ + +
+ @error('company-adress') + + {{$message}} + + @enderror +
+ +
+
+ + +
+ @error('company-mail') + + {{$message}} + + @enderror +
+ +
+
+ + +
+ @error('company-web') + + {{$message}} + + @enderror +
+ +
+
+ + +
+ + +
+ - + diff --git a/routes/web.php b/routes/web.php index 18cadf8d..6def19e0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -123,6 +123,7 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { Route::resource('configurations', ConfigurationController::class); Route::patch('settings/update/icons', [SettingsController::class, 'updateIcons'])->name('settings.update.icons'); + Route::patch('settings/update/invoice-settings', [SettingsController::class, 'updateInvoiceSettings'])->name('settings.update.invoicesettings'); Route::resource('settings', SettingsController::class)->only('index'); Route::get('usefullinks/datatable', [UsefulLinkController::class, 'datatable'])->name('usefullinks.datatable');