浏览代码

prepare the UI

1day2die 3 年之前
父节点
当前提交
ef3cc1e756

+ 24 - 27
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!');

+ 11 - 0
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!');
+    }
+
 }

+ 9 - 8
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));
     }
 }

+ 107 - 2
resources/views/admin/settings/index.blade.php

@@ -39,6 +39,9 @@
                         <li class="nav-item">
                             <a class="nav-link active" data-toggle="pill" href="#dashboard-icons">Dashboard icons</a>
                         </li>
+                        <li class="nav-item">
+                            <a class="nav-link" data-toggle="pill" href="#invoice-settings">Invoice Settings</a>
+                        </li>
                     </ul>
 
                     <!-- Tab panes -->
@@ -88,14 +91,116 @@
                                     chrome hotkey)</sup> to reload without cache to see your changes appear :)</p>
 
                         </div>
-                    </div>
 
+                            <div class="tab-pane mt-3" id="invoice-settings">
+                            <form method="POST" enctype="multipart/form-data" class="mb-3"
+                                  action="{{route('admin.settings.update.invoicesettings')}}">
+                                @csrf
+                                @method('PATCH')
+
+                                <div class="row">
+                                    <div class="col-md-6 col-lg-4 col-12">
+                                        <!-- Phone -->
+                                        <div class="form-group">
+                                            <div class="custom-file mb-3 mt-3">
+                                                <input type="text"
+                                                       class="custom-text-input" name="company-phone" id="company-phone">
+                                                <label class="custom-text-label selected"
+                                                       for="company-phone">{{__('Enter your Company Phone Number')}}</label>
+                                            </div>
+                                            @error('company-phone')
+                                            <span class="text-danger">
+                                                   {{$message}}
+                                               </span>
+                                            @enderror
+                                        </div>
+<!-- Name -->
+                                        <div class="form-group">
+                                            <div class="custom-file mb-3 mt-3">
+                                                <input type="text"
+                                                       class="custom-text-input" name="company-name" id="company-name">
+                                                <label class="custom-text-label selected"
+                                                       for="company-phone">{{__('Enter your Company Name')}}</label>
+                                            </div>
+                                            @error('company-name')
+                                            <span class="text-danger">
+                                                   {{$message}}
+                                               </span>
+                                            @enderror
+                                        </div>
+                                        <!-- VAT -->
+                                        <div class="form-group">
+                                            <div class="custom-file mb-3 mt-3">
+                                                <input type="text"
+                                                       class="custom-text-input" name="company-vat" id="company-vat">
+                                                <label class="custom-text-label selected"
+                                                       for="company-phone">{{__('Enter your Company VAT')}}</label>
+                                            </div>
+                                            @error('company-vat')
+                                            <span class="text-danger">
+                                                   {{$message}}
+                                               </span>
+                                            @enderror
+                                        </div>
+
+                                        <!-- adress -->
+                                        <div class="form-group">
+                                            <div class="custom-file mb-3 mt-3">
+                                                <input type="text"
+                                                       class="custom-text-input" name="company-adress" id="company-adress">
+                                                <label class="custom-text-label selected"
+                                                       for="company-phone">{{__('Enter your Company Adress')}}</label>
+                                            </div>
+                                            @error('company-adress')
+                                            <span class="text-danger">
+                                                   {{$message}}
+                                               </span>
+                                            @enderror
+                                        </div>
+                                        <!-- email -->
+                                        <div class="form-group">
+                                            <div class="custom-file mb-3 mt-3">
+                                                <input type="text"
+                                                       class="custom-text-input" name="company-mail" id="company-mail">
+                                                <label class="custom-text-label selected"
+                                                       for="company-phone">{{__('Enter your Company mail')}}</label>
+                                            </div>
+                                            @error('company-mail')
+                                            <span class="text-danger">
+                                                   {{$message}}
+                                               </span>
+                                            @enderror
+                                        </div>
+                                        <!-- website -->
+                                        <div class="form-group">
+                                            <div class="custom-file mb-3 mt-3">
+                                                <input type="text"
+                                                       class="custom-text-input" name="company-web" id="company-web">
+                                                <label class="custom-text-label selected"
+                                                       for="company-phone">{{__('Enter your Company web')}}</label>
+                                            </div>
+                                            @error('company-web')
+                                            <span class="text-danger">
+                                                   {{$message}}
+                                               </span>
+                                            @enderror
+                                        </div>
+
+                                    </div>
+                                </div>
+
+                                <button class="btn btn-primary">Submit</button>
+                            </form>
+
+
+                        </div>
+                    </div>
 
                 </div>
             </div>
 
 
-        </div>
+
         <!-- END CUSTOM CONTENT -->
 
     </section>

+ 1 - 0
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');