vendredi 28 avril 2017

Size limit when passing a variable to Mail:send laravel

I'm trying to pass a query result into a view, but I keep getting an error: Maximum execution time of 30 seconds exceeded I'm passing smaller objects through and its working fine, but it breaks when I pass the result of $monthlyBidStatment through. If there is a better way of doing this I'd really appreciate any advice. Thanks in advance.

public function sendEmailInvoice(Request $request)
    {
        $invoice = Invoice::where('id', '=', $request->invoiceId)->first();
        $startDate = $invoice->start_billing_date;
        $startDateSql = date("Y-m-d", strtotime($startDate));
        $endDate = $invoice->end_billing_date;
        $endDateSql = date("Y-m-d", strtotime($endDate));
        $affiliate = AffiliateDetail::where('id', '=', $invoice->affiliate_detail_id)->first();
        $monthlyBidStatment = BidTracker::where('affiliate_detail_id', '=', $affiliate->id)->whereBetween('created_at', [$startDateSql, $endDateSql])->get();

        // LOG::info(gettype($monthlyBidStatment));

        Mail::send('pdf.invoicePDF', [
            'oAffiliate' => $affiliate,
            'oInvoice' => $invoice,
            'bids' => $monthlyBidStatment,
            'showBreadcrumb' => false
        ], function ($m) use ($affiliate, $invoice, $monthlyBidStatment)
        {
            $m->from(env('APP_EMAIL'), env('APP_NAME'));
            $m->to($affiliate->info_billing_email, $affiliate->info_company_name)->subject(env('APP_NAME') . ' Invoice');
            $pdf = PDF::loadView('pdf.invoicePDF', [
                'oAffiliate' => $affiliate,
                'oInvoice' => $invoice,
                'bids' => $monthlyBidStatment,
                'showBreadcrumb' => false
            ]);

            $m->attachData($pdf->output(), 'invoice.pdf');
        });

        $request->session()->flash('message', 'Successfully sent email invoice');
        return array(
            'status' => 'ok'
        );
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire