首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >DOMPDF - Laravel -电子邮件PDF及其附件

DOMPDF - Laravel -电子邮件PDF及其附件
EN

Stack Overflow用户
提问于 2018-09-11 23:58:37
回答 3查看 1K关注 0票数 1

我收到了这个错误,原因是什么?

“未定义变量:报价”

QuotationController.php

代码语言:javascript
复制
public function update(Request $request, Quotation $quotation)
    {
      {


          $quotation->description= $request['description'];
          $quotation->qty= $request['qty'];
          $quotation->each_price= $request['each_price'];
          $quotation->save();

         $info = ['info'=>$quotation];

         Mail::send(['text'=>'mail'], $info, function($message){

             $pdf = PDF::loadView('employees.quotations.edit', $quotation);

             $message->to('example@gmail.com','John Doe')->subject('Quotation');

             $message->from('from@gmail.com','The Sender');

             $message->attachData($pdf->output(), 'filename.pdf');

           });
          echo 'Email was sent!';

        }
      }

public function edit(Quotation $quotation)
    {
        return view('employees.quotations.edit', compact('quotation'));
        //return view('employees.quotations.edit')->with('quotation');

    }

......................................................................

路由看起来像这样的

代码语言:javascript
复制
Route::post('/quotation', 'Employee\QuotationController@store')->name('employee.quotation.store');
  Route::get('/quotation', 'Employee\QuotationController@index')->name('employee.quotation.index');
  Route::get('/quotation/create', 'Employee\QuotationController@create')->name('employee.quotation.create');
  Route::put('/quotation/{quotation}', 'Employee\QuotationController@update')->name('employee.quotation.update');
  Route::get('/quotation/{quotation}', 'Employee\QuotationController@show')->name('employee.quotation.show');
  Route::delete('/quotation/{quotation}', 'Employee\QuotationController@destroy')->name('employee.quotation.destroy');
  Route::get('/quotation/{quotation}/edit', 'Employee\QuotationController@edit')->name('employee.quotation.edit');

employees.quotations.edit.blade.php看起来像这样的

代码语言:javascript
复制
@section('left-menu')

@endsection

@section('right-menu')

@endsection

@section('content')
  <h1>Update a Quotation</h1>
  <br><br>

    <form action="{{ route('employee.quotation.update',$quotation->id) }}" method="post">
      @method('PUT')
      @csrf
      <div class="form-group">
        <label for="inputJobDescription">Description</label>
        <textarea class="form-control" rows="2" id="inputQuoteDescription" name="description" placeholder="Description">{{$quotation->description}}
</textarea>
      </div>
      <div class="form-group row">
        <label for="inputQty" class="col-2 col-form-label">Qty</label>
        <div class="col-10">
          <input type="text" class="form-control" id="inputQty" name="qty" value="{{$quotation->qty}}" oninput="quotation_calculate()" onchange="quotation_calculate()">
        </div>
      </div>
      <div class="form-group row">
        <label for="inputEachPrice" class="col-2 col-form-label">Each Price</label>
        <div class="col-10">
          <input type="text" class="form-control" id="inputEachPrice" name="each_price" value="{{$quotation->each_price}}" oninput="quotation_calculate()" onchange="quotation_calculate()">
        </div>
      </div>
      <button type="submit" class="btn btn-primary">Submit</button>
    </form>
@endsection

@section('pagescript')

@stop

这里我漏掉了什么?我已经将$quotation传递给了编辑视图

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52279938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档