- Created a new Blade view for managing brand contracts with forms for adding and editing contracts, including client and category selection. - Implemented success message notifications for contract actions. - Added a new Blade view for invoice settings, allowing customization of invoice number format, header branding, and default values for new invoices. - Introduced a new PDF view for generating rate cards with customizable styles based on user profile settings. - Developed a profile management page for rate cards, enabling users to update their identity, appearance, and visibility settings.
56 lines
2.0 KiB
PHP
56 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\InvoiceSettings;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\View\View;
|
|
|
|
class InvoiceSettingsController extends Controller
|
|
{
|
|
public function edit(): View
|
|
{
|
|
$settings = InvoiceSettings::instance();
|
|
return view('invoices.settings', compact('settings'));
|
|
}
|
|
|
|
public function update(Request $request): RedirectResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'invoice_prefix' => 'required|string|max:20',
|
|
'invoice_next_number' => 'required|integer|min:1',
|
|
'header_name' => 'nullable|string|max:100',
|
|
'header_title' => 'nullable|string|max:150',
|
|
'header_logo' => 'nullable|image|max:2048',
|
|
'default_tax_rate' => 'nullable|numeric|min:0|max:100',
|
|
'default_currency' => 'nullable|string|max:10',
|
|
'default_service_description'=> 'nullable|string|max:255',
|
|
'default_bank_name' => 'nullable|string|max:100',
|
|
'default_branch_name' => 'nullable|string|max:100',
|
|
'default_bank_account' => 'nullable|string|max:50',
|
|
'default_bank_holder' => 'nullable|string|max:100',
|
|
'default_notes' => 'nullable|string|max:1000',
|
|
]);
|
|
|
|
$settings = InvoiceSettings::instance();
|
|
|
|
if ($request->hasFile('header_logo')) {
|
|
// Delete old logo if exists
|
|
if ($settings->header_logo) {
|
|
Storage::disk('public')->delete($settings->header_logo);
|
|
}
|
|
$path = $request->file('header_logo')->store('invoice-logos', 'public');
|
|
$validated['header_logo'] = $path;
|
|
}
|
|
|
|
$settings->update($validated);
|
|
|
|
return redirect()->route('invoice-settings.edit')
|
|
->with('success', '🧾 Invoice settings saved!');
|
|
}
|
|
}
|