invoice settings via DB and changeable
This commit is contained in:
parent
9d64eaf73f
commit
7f4503d228
6 changed files with 41 additions and 13 deletions
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||||
use App\Events\UserUpdateCreditsEvent;
|
use App\Events\UserUpdateCreditsEvent;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Configuration;
|
use App\Models\Configuration;
|
||||||
|
use App\Models\invoiceSettings;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaypalProduct;
|
use App\Models\PaypalProduct;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
@ -194,17 +195,18 @@ class PaymentController extends Controller
|
||||||
event(new UserUpdateCreditsEvent($user));
|
event(new UserUpdateCreditsEvent($user));
|
||||||
|
|
||||||
//create invoice
|
//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') . "%")->count("id");
|
||||||
$newInvoiceID = $lastInvoiceID + 1;
|
$newInvoiceID = $lastInvoiceID + 1;
|
||||||
|
$invoiceSettings = invoiceSettings::all()->first();
|
||||||
|
|
||||||
$seller = new Party([
|
$seller = new Party([
|
||||||
'name' => env("APP_NAME", "Controlpanel.gg"),
|
'name' => $invoiceSettings->company_name,
|
||||||
'phone' => env("COMPANY_PHONE", ""),
|
'phone' => $invoiceSettings->company_phone,
|
||||||
'address' => env("COMPANY_ADRESS", ""),
|
'address' => $invoiceSettings->company_adress,
|
||||||
'vat' => env("COMPANY_VAT_ID", ""),
|
'vat' => $invoiceSettings->company_vat,
|
||||||
'custom_fields' => [
|
'custom_fields' => [
|
||||||
'E-Mail' => env("MAIL_FROM_ADDRESS", "company@mail.com"),
|
'E-Mail' => $invoiceSettings->company_mail,
|
||||||
"Web" => env("APP_URL", "https://controlpanel.gg")
|
"Web" => $invoiceSettings->company_web
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -230,7 +232,7 @@ class PaymentController extends Controller
|
||||||
->delimiter("-")
|
->delimiter("-")
|
||||||
->sequence($newInvoiceID)
|
->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'));
|
->logo(storage_path('app/public/logo.png'));
|
||||||
|
|
||||||
//Save the invoice in "storage\app\invoice\USER_ID\YEAR"
|
//Save the invoice in "storage\app\invoice\USER_ID\YEAR"
|
||||||
$invoice->filename = $invoice->getSerialNumber() . '.pdf';
|
$invoice->filename = $invoice->getSerialNumber() . '.pdf';
|
||||||
|
@ -245,7 +247,7 @@ class PaymentController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//Send Invoice per Mail
|
//Send Invoice per Mail
|
||||||
$user->notify(new InvoiceNotification($invoice, $user, $payment));
|
//$user->notify(new InvoiceNotification($invoice, $user, $payment));
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
return redirect()->route('home')->with('success', 'Your credit balance has been increased!');
|
return redirect()->route('home')->with('success', 'Your credit balance has been increased!');
|
||||||
|
|
|
@ -43,12 +43,34 @@ class SettingsController extends Controller
|
||||||
public function updateInvoiceSettings(Request $request)
|
public function updateInvoiceSettings(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'icon' => 'nullable',
|
'logo' => 'nullable|max:10000|mimes:jpg,png,jpeg',
|
||||||
'favicon' => 'nullable',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($request->filled('company-name')) {
|
||||||
|
invoiceSettings::updateOrCreate(['id' => "1"],['company_name' => $request->get('company-name')]);
|
||||||
|
}
|
||||||
|
if($request->filled('company-adress')) {
|
||||||
|
invoiceSettings::updateOrCreate(['id' => "1",],['company_adress' => $request->get('company-adress')]);
|
||||||
|
}
|
||||||
|
if($request->filled('company-phone')) {
|
||||||
|
invoiceSettings::updateOrCreate(['id' => "1",],['company_phone' => $request->get('company-phone')]);
|
||||||
|
}
|
||||||
|
if($request->filled('company-vat')) {
|
||||||
|
invoiceSettings::updateOrCreate(['id' => "1",],['company_vat' => $request->get('company-vat')]);
|
||||||
|
}
|
||||||
|
if($request->filled('company-mail')) {
|
||||||
|
invoiceSettings::updateOrCreate(['id' => "1",],['company_mail' => $request->get('company-mail')]);
|
||||||
|
}
|
||||||
|
if($request->filled('company-web')) {
|
||||||
|
invoiceSettings::updateOrCreate(['id' => "1",],['company_web' => $request->get('company-web')]);
|
||||||
|
}
|
||||||
|
if ($request->hasFile('logo')) {
|
||||||
|
$request->file('logo')->storeAs('public', 'logo.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return redirect()->route('admin.settings.index')->with('success', 'Invoice settings updated!');
|
return redirect()->route('admin.settings.index')->with('success', 'Invoice settings updated!');
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@ use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class ConfirmPaymentNotification extends Notification implements ShouldQueue
|
class ConfirmPaymentNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
||||||
|
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
private Payment $payment;
|
private Payment $payment;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use Database\Seeders\Seeds\ConfigurationSeeder;
|
use Database\Seeders\Seeds\ConfigurationSeeder;
|
||||||
|
use Database\Seeders\Seeds\InvoiceSettingsSeeder;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
|
|
BIN
public/vendor/invoices/logo.png
vendored
BIN
public/vendor/invoices/logo.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
|
@ -203,13 +203,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button class="btn btn-primary">Submit</button>
|
||||||
<!-- end -->
|
<!-- end -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary">Submit</button>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue