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:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CustomerPortal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\EstimateResource;
|
||||
use App\Mail\EstimateViewedMail;
|
||||
use App\Models\CompanySetting;
|
||||
use App\Models\Customer;
|
||||
use App\Models\EmailLog;
|
||||
use App\Models\Estimate;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EstimatePdfController extends Controller
|
||||
{
|
||||
public function getPdf(EmailLog $emailLog, Request $request)
|
||||
{
|
||||
$estimate = Estimate::find($emailLog->mailable_id);
|
||||
|
||||
if (! $emailLog->isExpired()) {
|
||||
if ($estimate && ($estimate->status == Estimate::STATUS_SENT || $estimate->status == Estimate::STATUS_DRAFT)) {
|
||||
$estimate->status = Estimate::STATUS_VIEWED;
|
||||
$estimate->save();
|
||||
$notifyEstimateViewed = CompanySetting::getSetting(
|
||||
'notify_estimate_viewed',
|
||||
$estimate->company_id
|
||||
);
|
||||
|
||||
if ($notifyEstimateViewed == 'YES') {
|
||||
$data['estimate'] = Estimate::findOrFail($estimate->id)->toArray();
|
||||
$data['user'] = Customer::find($estimate->customer_id)->toArray();
|
||||
$notificationEmail = CompanySetting::getSetting(
|
||||
'notification_email',
|
||||
$estimate->company_id
|
||||
);
|
||||
|
||||
\Mail::to($notificationEmail)->send(new EstimateViewedMail($data));
|
||||
}
|
||||
}
|
||||
|
||||
return $estimate->getGeneratedPDFOrStream('estimate');
|
||||
}
|
||||
|
||||
abort(403, 'Link Expired.');
|
||||
}
|
||||
|
||||
public function getEstimate(EmailLog $emailLog)
|
||||
{
|
||||
$estimate = Estimate::find($emailLog->mailable_id);
|
||||
|
||||
return new EstimateResource($estimate);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user