mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Rename controller namespaces: drop V1 prefix, clarify roles
V1/Admin -> Company (company-scoped controllers) V1/SuperAdmin -> Admin (platform-wide admin controllers) V1/Customer -> CustomerPortal (customer-facing portal) V1/Installation -> Setup (installation wizard) V1/PDF -> Pdf (consistent casing) V1/Modules -> Modules (drop V1 prefix) V1/Webhook -> Webhook (drop V1 prefix) The V1 prefix served no purpose - API versioning is in the route prefix (/api/v1/), not the controller namespace. "Admin" was misleading for company-scoped controllers. "SuperAdmin" is now simply "Admin" for platform administration.
This commit is contained in:
61
app/Http/Controllers/CustomerPortal/InvoicePdfController.php
Normal file
61
app/Http/Controllers/CustomerPortal/InvoicePdfController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CustomerPortal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\Customer\InvoiceResource as CustomerInvoiceResource;
|
||||
use App\Mail\InvoiceViewedMail;
|
||||
use App\Models\CompanySetting;
|
||||
use App\Models\Customer;
|
||||
use App\Models\EmailLog;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoicePdfController extends Controller
|
||||
{
|
||||
public function getPdf(EmailLog $emailLog, Request $request)
|
||||
{
|
||||
$invoice = Invoice::find($emailLog->mailable_id);
|
||||
|
||||
if (! $emailLog->isExpired()) {
|
||||
if ($invoice && ($invoice->status == Invoice::STATUS_SENT || $invoice->status == Invoice::STATUS_DRAFT)) {
|
||||
$invoice->status = Invoice::STATUS_VIEWED;
|
||||
$invoice->viewed = true;
|
||||
$invoice->save();
|
||||
$notifyInvoiceViewed = CompanySetting::getSetting(
|
||||
'notify_invoice_viewed',
|
||||
$invoice->company_id
|
||||
);
|
||||
|
||||
if ($notifyInvoiceViewed == 'YES') {
|
||||
$data['invoice'] = Invoice::findOrFail($invoice->id)->toArray();
|
||||
$data['user'] = Customer::find($invoice->customer_id)->toArray();
|
||||
$notificationEmail = CompanySetting::getSetting(
|
||||
'notification_email',
|
||||
$invoice->company_id
|
||||
);
|
||||
|
||||
\Mail::to($notificationEmail)->send(new InvoiceViewedMail($data));
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->has('pdf')) {
|
||||
return $invoice->getGeneratedPDFOrStream('invoice');
|
||||
}
|
||||
|
||||
return view('app')->with([
|
||||
'customer_logo' => get_company_setting('customer_portal_logo', $invoice->company_id),
|
||||
'current_theme' => get_company_setting('customer_portal_theme', $invoice->company_id),
|
||||
]);
|
||||
}
|
||||
|
||||
abort(403, 'Link Expired.');
|
||||
}
|
||||
|
||||
public function getInvoice(EmailLog $emailLog)
|
||||
{
|
||||
$invoice = Invoice::find($emailLog->mailable_id);
|
||||
|
||||
return new CustomerInvoiceResource($invoice);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user