app\models\Invoice::getFileName PHP Method

getFileName() public method

public getFileName ( ) : string
return string
    public function getFileName()
    {
        $entityType = $this->getEntityType();
        return trans("texts.{$entityType}") . '_' . $this->invoice_number . '.pdf';
    }

Usage Example

 /**
  * @param Invitation $invitation
  * @param Invoice $invoice
  * @param $body
  * @param $subject
  * @param $pdfString
  * @param $documentStrings
  * @return bool|string
  * @throws \Laracasts\Presenter\Exceptions\PresenterException
  */
 private function sendInvitation(Invitation $invitation, Invoice $invoice, $body, $subject, $pdfString, $documentStrings)
 {
     $client = $invoice->client;
     $account = $invoice->account;
     if (Auth::check()) {
         $user = Auth::user();
     } else {
         $user = $invitation->user;
         if ($invitation->user->trashed()) {
             $user = $account->users()->orderBy('id')->first();
         }
     }
     if (!$user->email || !$user->registered) {
         return trans('texts.email_error_user_unregistered');
     } elseif (!$user->confirmed) {
         return trans('texts.email_error_user_unconfirmed');
     } elseif (!$invitation->contact->email) {
         return trans('texts.email_error_invalid_contact_email');
     } elseif ($invitation->contact->trashed()) {
         return trans('texts.email_error_inactive_contact');
     }
     $variables = ['account' => $account, 'client' => $client, 'invitation' => $invitation, 'amount' => $invoice->getRequestedAmount()];
     // Let the client know they'll be billed later
     if ($client->autoBillLater()) {
         $variables['autobill'] = $invoice->present()->autoBillEmailMessage();
     }
     if (empty($invitation->contact->password) && $account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $account->enable_portal_password && $account->send_portal_password) {
         // The contact needs a password
         $variables['password'] = $password = $this->generatePassword();
         $invitation->contact->password = bcrypt($password);
         $invitation->contact->save();
     }
     $data = ['body' => $this->templateService->processVariables($body, $variables), 'link' => $invitation->getLink(), 'entityType' => $invoice->getEntityType(), 'invoiceId' => $invoice->id, 'invitation' => $invitation, 'account' => $account, 'client' => $client, 'invoice' => $invoice, 'documents' => $documentStrings];
     if ($account->attachPDF()) {
         $data['pdfString'] = $pdfString;
         $data['pdfFileName'] = $invoice->getFileName();
     }
     $subject = $this->templateService->processVariables($subject, $variables);
     $fromEmail = $user->email;
     $view = $account->getTemplateView(ENTITY_INVOICE);
     $response = $this->sendTo($invitation->contact->email, $fromEmail, $account->getDisplayName(), $subject, $view, $data);
     if ($response === true) {
         return true;
     } else {
         return $response;
     }
 }