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\Http\Controllers\Controller;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\invoiceSettings;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaypalProduct;
|
||||
use App\Models\User;
|
||||
|
@ -194,17 +195,18 @@ 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') . "%")->count("id");
|
||||
$newInvoiceID = $lastInvoiceID + 1;
|
||||
$invoiceSettings = invoiceSettings::all()->first();
|
||||
|
||||
$seller = new Party([
|
||||
'name' => env("APP_NAME", "Controlpanel.gg"),
|
||||
'phone' => env("COMPANY_PHONE", ""),
|
||||
'address' => env("COMPANY_ADRESS", ""),
|
||||
'vat' => env("COMPANY_VAT_ID", ""),
|
||||
'name' => $invoiceSettings->company_name,
|
||||
'phone' => $invoiceSettings->company_phone,
|
||||
'address' => $invoiceSettings->company_adress,
|
||||
'vat' => $invoiceSettings->company_vat,
|
||||
'custom_fields' => [
|
||||
'E-Mail' => env("MAIL_FROM_ADDRESS", "company@mail.com"),
|
||||
"Web" => env("APP_URL", "https://controlpanel.gg")
|
||||
'E-Mail' => $invoiceSettings->company_mail,
|
||||
"Web" => $invoiceSettings->company_web
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -230,7 +232,7 @@ class PaymentController extends Controller
|
|||
->delimiter("-")
|
||||
->sequence($newInvoiceID)
|
||||
->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"
|
||||
$invoice->filename = $invoice->getSerialNumber() . '.pdf';
|
||||
|
@ -245,7 +247,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!');
|
||||
|
|
|
@ -43,12 +43,34 @@ class SettingsController extends Controller
|
|||
public function updateInvoiceSettings(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'icon' => 'nullable',
|
||||
'favicon' => 'nullable',
|
||||
'logo' => 'nullable|max:10000|mimes:jpg,png,jpeg',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
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!');
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ use Illuminate\Notifications\Notification;
|
|||
|
||||
class ConfirmPaymentNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
|
||||
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
|
||||
|
||||
use Queueable;
|
||||
|
||||
private Payment $payment;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Database\Seeders;
|
||||
|
||||
use Database\Seeders\Seeds\ConfigurationSeeder;
|
||||
use Database\Seeders\Seeds\InvoiceSettingsSeeder;
|
||||
use Illuminate\Database\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>
|
||||
|
||||
<button class="btn btn-primary">Submit</button>
|
||||
<!-- end -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary">Submit</button>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue