Home > database >  Laravel when sending mail giving unparenthesized expressions error
Laravel when sending mail giving unparenthesized expressions error

Time:04-22

I am trying to send mail but it is giving this error:

The behavior of unparenthesized expressions containing both '.' and ' '/'-' will change in PHP 8: ' '/'-' will take a higher precedence

following is my code in controller

                Employee::
                    where("organization_id", $billing->organization_id)
                    ->permission([ Permission::BILLINGS_FULL_ACCESS ])
                    ->withAllOrganizations()
                    ->get()
                    ->map(function($employee) use($billing) {
                        Mail::to($employee->work_email)->send(new BillingMail($billing));
                    });

and this my mail code:

class BillingMail extends Mailable

{ use Queueable, SerializesModels;

protected $billing;

/**
 * Create a new message instance.
 *
 * @return void
 */
public function __construct($billing)
{
    $this->billing = $billing->load("organizations", "purchases");
}

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    $pdf = new BillingPDF();
    $pdf->AddSlip($this->billing);
    $pdfName = "Invoice-" . $this->billing->id   20220301;

    $email = $this->subject("Tankhwa billing")
                ->view('emails.billing')
                ->attachData($pdf->Output('S', $pdfName), $pdfName, [
                    'mime' => 'application/pdf'
                ])
                ->with([
                    "billing" => $this->billing
                ]);
    return $email;
}

my other mail are sending which have used same logic but this one is giving error please someone help.

CodePudding user response:

The problem is likely encountered in this line

$pdfName = "Invoice-" . $this->billing->id   20220301;

Try changing it to

$value = $this->billing->id   20220301;
$pdfName = "Invoice-" . $value;

More information: The behavior of unparenthesized expressions containing both '.' and ' '/'-' will change in PHP 8: ' '/'-' will take a higher precedence

  • Related