ローカル環境では動いていたプログラムが本番環境で動作しなくなりました。
環境
php:5.7
macos:10.14.1
laravel:5.8
サクラ:ライトプラン
env
1MAIL_DRIVER=smtp 2MAIL_HOST=smtp.mailtrap.io 3MAIL_PORT=2525 4MAIL_USERNAME=972f0b7f827e59 5MAIL_PASSWORD=615880b3ced340 6MAIL_FROM_ADDRESS=0000@example.com 7MAIL_FROM_NAME='000000' 8MAIL_ENCRYPTION=ssl
やりたいこととしてはPDFにしたファイルをメールで送信するといった作業です。
CartControler
1 public function pdf() { 2 $carts = Cart::content(); 3 $day = date("Y/m/d"); 4 $user = Auth::user(); 5 foreach($carts as $cart){ 6 $maker = $cart->options->maker; 7 $pic = Manufacturer::where('m_name','=',$maker)->value('pic'); 8 $mail = Manufacturer::where('m_name','=',$maker)->value('mail'); 9 $history = new History; 10 $history->m_id = $cart->id; 11 $history->p_number = $cart->options->p_number; 12 $history->item = $cart->name; 13 $history->quanty = $cart->qty; 14 $history->amount = $cart->price*$cart->qty; 15 $history->customer = $user->name; 16 $history->order_date = $day; 17 $history->save(); 18 } 19 $pdf = app('dompdf.wrapper'); 20 $pdf->loadView('cart_pdf', ['carts' => $carts,'maker' =>$maker,'pic'=>$pic,'day'=>$day]); 21 22 $pdf = PDF::loadView('cart_pdf', compact('carts','maker','pic','day')); 23 Mail::to($mail)->send(new Order($pic,$pdf)); 24 25 Cart::destroy(); 26 27 return $pdf->download('cart_pdf'); 28 } 29
blad
1 2<!doctype html> 3<html> 4<head> 5<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 6<title>Create PDF</title> 7<style> 8body { 9font-family: ipag; 10} 11</style> 12 13</head> 14<body> 15<div class="page container"> 16 <div class="page-section list-content" style="padding-top: 30px;"> 17 <div align="center"> 18 <h1>発注書</h1> 19 </div> 20 <div align="right"> 21 <h3>発注日:{{ $day }}</h3> 22 </div> 23 <br><br> 24 <div align="left"> 25 <h2><u>{{ $maker }} 御中</u></h2> 26 </div> 27 <br> 28 <div align="left"> 29 @isset($pic) 30 <h4><u>担当: {{ $pic }}様</u></h4> 31 @endisset 32 </div> 33 </div> 34 <div class="page-section list-content" style="padding-top: 30px;"> 35 <table align="center" border="1" width="800" cellspacing="0" cellpadding="5" > 36 <thead> 37 <tr> 38 <th>品名</th> 39 <th>品番</th> 40 <th>単価</th> 41 <th>数量</th> 42 <th>小計</th> 43 <th>納期</th> 44 </tr> 45 </thead> 46 <tbody> 47 @foreach($carts as $cart) 48 49 <tr> 50 <td> 51 {{ $cart->name }} 52 53 </td> 54 <td> 55 {{ $cart->options->p_number }} 56 </td> 57 <td> 58 {{ $cart->price }} 59 </td> 60 <td> 61 {{ $cart->qty }} 62 </td> 63 <td> 64 {{ $cart->qty * $cart->price }} 65 </td> 66 <td> 67 {{ $cart->options->delivery }} 68 </td> 69 </tr> 70 @endforeach 71 </tbody> 72 </table> 73 </div> 74
メールの設定でエラーが出ているのか、dompdfが作動していないのかわかりません。
回答1件
あなたの回答
tips
プレビュー