propoosalRepo = $propoosalRepo; } public function viewProposal($invitationKey) { if (! $invitation = $this->propoosalRepo->findInvitationByKey($invitationKey)) { return $this->returnError(trans('texts.proposal_not_found')); } $account = $invitation->account; $proposal = $invitation->proposal; $invoiceInvitation = Invitation::whereContactId($invitation->contact_id) ->whereInvoiceId($proposal->invoice_id) ->firstOrFail(); $data = [ 'proposal' => $proposal, 'account' => $account, 'invoiceInvitation' => $invoiceInvitation, 'proposalInvitation' => $invitation, ]; if (request()->phantomjs) { return $proposal->present()->htmlDocument; } else { return view('invited.proposal', $data); } } public function downloadProposal($invitationKey) { if (! $invitation = $this->propoosalRepo->findInvitationByKey($invitationKey)) { return $this->returnError(trans('texts.proposal_not_found')); } $proposal = $invitation->proposal; $pdf = dispatch_now(new ConvertProposalToPdf($proposal)); $this->downloadResponse($proposal->getFilename(), $pdf); } public function getProposalImage($accountKey, $documentKey) { $account = Account::whereAccountKey($accountKey) ->firstOrFail(); $document = Document::whereAccountId($account->id) ->whereDocumentKey($documentKey) ->whereIsProposal(true) ->firstOrFail(); return DocumentController::getDownloadResponse($document); } }