diff --git a/.gitignore b/.gitignore index 02dee0df..dbcf5907 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ yarn-error.log .env.dev .env.testing storage/invoices.zip +storage/app/public/logo.png diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index e892ee18..aebeca3e 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -198,6 +198,7 @@ class PaymentController extends Controller $lastInvoiceID = \App\Models\Invoice::where("invoice_name", "like", "%" . now()->format('mY') . "%")->count("id"); $newInvoiceID = $lastInvoiceID + 1; $InvoiceSettings = InvoiceSettings::all()->first(); + $logoPath = storage_path('app/public/logo.png'); $seller = new Party([ 'name' => $InvoiceSettings->company_name, @@ -231,16 +232,18 @@ class PaymentController extends Controller ->series(now()->format('mY')) ->delimiter("-") ->sequence($newInvoiceID) - ->serialNumberFormat(env("INVOICE_PREFIX", "INV") . '{DELIMITER}{SERIES}{SEQUENCE}') - ->logo(storage_path('app/public/logo.png')); + ->serialNumberFormat($InvoiceSettings->invoice_prefix . '{DELIMITER}{SERIES}{SEQUENCE}'); + if (file_exists($logoPath)) { + $invoice->logo($logoPath); + } //Save the invoice in "storage\app\invoice\USER_ID\YEAR" $invoice->filename = $invoice->getSerialNumber() . '.pdf'; $invoice->render(); Storage::disk("local")->put("invoice/" . $user->id . "/" . now()->format('Y') . "/" . $invoice->filename, $invoice->output); - \App\Models\invoice::create([ + \App\Models\Invoice::create([ 'invoice_user' => $user->id, 'invoice_name' => $invoice->getSerialNumber(), 'payment_id' => $payment->payment_id, diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 83297040..ef7ea068 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -27,7 +27,8 @@ class SettingsController extends Controller '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 + 'company_web' => invoiceSettings::get()->first()->company_web, + 'invoice_prefix' => invoiceSettings::get()->first()->invoice_prefix ]); } @@ -61,6 +62,7 @@ class SettingsController extends Controller 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')]); if ($request->hasFile('logo')) { $request->file('logo')->storeAs('public', 'logo.png'); diff --git a/app/Models/InvoiceSettings.php b/app/Models/InvoiceSettings.php index 8e2d5a08..c246f165 100644 --- a/app/Models/InvoiceSettings.php +++ b/app/Models/InvoiceSettings.php @@ -17,6 +17,7 @@ class InvoiceSettings extends Model 'company_phone', 'company_mail', 'company_vat', - 'company_web' + 'company_web', + 'invoice_prefix' ]; } diff --git a/resources/views/admin/settings/index.blade.php b/resources/views/admin/settings/index.blade.php index 9639dd32..c1f17642 100644 --- a/resources/views/admin/settings/index.blade.php +++ b/resources/views/admin/settings/index.blade.php @@ -165,6 +165,17 @@ + +
+
+ + +
+
+
diff --git a/storage/app/public/logo.png b/storage/app/public/logo.png deleted file mode 100644 index f2afb9c3..00000000 Binary files a/storage/app/public/logo.png and /dev/null differ