mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-01 21:00:58 +00:00
refactor: adopt modular domain architecture (#747)
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Sales\Http\Controllers\CustomerPortal;
|
||||
|
||||
use App\Domains\Accounts\Models\CompanySetting;
|
||||
use App\Domains\Contacts\Models\Customer;
|
||||
use App\Domains\Sales\Http\Resources\EstimateResource;
|
||||
use App\Domains\Sales\Mail\EstimateViewedMail;
|
||||
use App\Domains\Sales\Models\Estimate;
|
||||
use App\Platform\Http\Controller;
|
||||
use App\Platform\Mail\Models\EmailLog;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EstimatePdfController extends Controller
|
||||
{
|
||||
public function getPdf(EmailLog $emailLog, Request $request)
|
||||
{
|
||||
$estimate = $emailLog->mailable;
|
||||
abort_unless($estimate instanceof Estimate, 404);
|
||||
abort_if($emailLog->isExpired(), 403, 'Link Expired.');
|
||||
|
||||
if ($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');
|
||||
}
|
||||
|
||||
public function getEstimate(EmailLog $emailLog)
|
||||
{
|
||||
$estimate = $emailLog->mailable;
|
||||
abort_unless($estimate instanceof Estimate, 404);
|
||||
abort_if($emailLog->isExpired(), 403, 'Link Expired.');
|
||||
|
||||
return new EstimateResource($estimate);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user