问题描述
我正在使用dompdf并尝试下载pdf。我正在尝试调用从我的 nova action 文件下载pdf的方法,它也没有显示错误,但PDF并未下载。
任何快速建议都会有所帮助
我的动作文件
DownloadOrganizationReportPDF.php:
<?php
namespace App\Nova\Actions;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\ActionFields;
class DownloadOrganizationReportPDF extends Action
{
use InteractsWithQueue,Queueable;
/**
* Perform the action on the given models.
*
* @param \Laravel\Nova\Fields\ActionFields $fields
* @param \Illuminate\Support\Collection $models
* @return mixed
*/
public function handle(ActionFields $fields,Collection $models)
{
$invoiceController = new \App\Http\Controllers\InvoiceController();
return $invoiceController->makePDF();
}
/**
* Get the fields available on the action.
*
* @return array
*/
public function fields()
{
return [];
}
}
我的控制器
InvoiceController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use PDF;
class InvoiceController extends Controller
{
public function makePDF()
{
$pdf = PDF::loadView('report');
return $pdf->download('invoice.pdf');
}
}
我的查看文件
report.blade.php:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>check</title>
</head>
<body>
<h1>test</h1>
</body>
</html>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)