AVMG20 3 years ago
parent
commit
c6cfa6cd2f

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

@@ -197,7 +197,7 @@ class PaymentController extends Controller
                 //create invoice
                 $lastInvoiceID = \App\Models\Invoice::where("invoice_name", "like", "%" . now()->format('mY') . "%")->count("id");
                 $newInvoiceID = $lastInvoiceID + 1;
-                $InvoiceSettings = InvoiceSettings::all()->first();
+                $InvoiceSettings = InvoiceSettings::query()->first();
                 $logoPath = storage_path('app/public/logo.png');
 
                 $seller = new Party([

+ 15 - 17
app/Http/Controllers/Admin/SettingsController.php

@@ -20,16 +20,10 @@ class SettingsController extends Controller
      */
     public function index()
     {
-        return view('admin.settings.index',
-            [
-                'company_name' => InvoiceSettings::get()->first()->company_name,
-                'company_adress' => InvoiceSettings::get()->first()->company_adress,
-                'company_phone' => InvoiceSettings::get()->first()->company_phone,
-                'company_vat' => InvoiceSettings::get()->first()->company_vat,
-                'company_mail' => InvoiceSettings::get()->first()->company_mail,
-                'company_web' => InvoiceSettings::get()->first()->company_web,
-                'invoice_prefix' => InvoiceSettings::get()->first()->invoice_prefix
-            ]);
+        /** @var InvoiceSettings $invoiceSettings */
+        $invoiceSettings = InvoiceSettings::first();
+
+        return view('admin.settings.index', $invoiceSettings->toArray());
     }
 
     public function updateIcons(Request $request)
@@ -56,13 +50,17 @@ class SettingsController extends Controller
             'logo' => 'nullable|max:10000|mimes:jpg,png,jpeg',
         ]);
 
-        InvoiceSettings::updateOrCreate(['id' => "1"], ['company_name' => $request->get('company-name')]);
-        InvoiceSettings::updateOrCreate(['id' => "1",], ['company_adress' => $request->get('company-adress')]);
-        InvoiceSettings::updateOrCreate(['id' => "1",], ['company_phone' => $request->get('company-phone')]);
-        InvoiceSettings::updateOrCreate(['id' => "1",], ['company_mail' => $request->get('company-mail')]);
-        InvoiceSettings::updateOrCreate(['id' => "1",], ['company_vat' => $request->get('company-vat')]);
-        InvoiceSettings::updateOrCreate(['id' => "1",], ['company_web' => $request->get('company-web')]);
-        InvoiceSettings::updateOrCreate(['id' => "1",], ['invoice_prefix' => $request->get('invoice-prefix')]);
+        InvoiceSettings::updateOrCreate([
+            'id' => "1"
+        ], [
+            'company_name' => $request->get('company-name'),
+            'company_adress' => $request->get('company-adress'),
+            'company_phone' => $request->get('company-phone'),
+            'company_mail' => $request->get('company-mail'),
+            'company_vat' => $request->get('company-vat'),
+            'company_web' => $request->get('company-web'),
+            'invoice_prefix' => $request->get('invoice-prefix'),
+        ]);
 
         if ($request->hasFile('logo')) {
             $request->file('logo')->storeAs('public', 'logo.png');