尝试在Laravel中创建pdf文档时失败

时间:2018-12-11 22:04:14

标签: php laravel pdf laravel-5 pdf-generation

我有一个继承自Laravel 5.0.35的网站,它具有活动和非活动两个功能,该功能读取人员数据库并查看状态字段以生成PDF文档。

有效功能有效,但无效功能无效。它将引发以下错误:

  File.php第41行中的

FileNotFoundException:   文件“ ... / laravel / app / PDFs / individual / inactive-participants.1544562943.pdf”不存在   在File.php第41行中

     

在BinaryFileResponse.php第91行的File-> __ construct('... / laravel / app / PDFs / individual / inactive-participants.1544562943.pdf')中

     

在BinaryFileResponse-> setFile('... / laravel / app / PDFs / individual / inactive-participants.1544562943.pdf','attachment',false,true)在BinaryFileResponse.php第50行中

     

在BinaryFileResponse-> __ construct('... / laravel / app / PDFs / individual / inactive-participants.1544562943.pdf'-ResponseFactory.php中的'200',array(),true,'attachment')第129行

     

在ResponseFactory-> downloads('... / laravel / app / PDFs / individual / inactive-participants.1544562943.pdf')在ReportsController.php第200行中

函数如下:

public function gInctve(Request $request)
{
    $tokenName = $request->get('tokenName');
    Cookie::queue($tokenName, $tokenName, 1, null, null, false, false);

    $fullPaths = [];
    $time = time();

    People::with('upple', 'plans.share')
        ->with(['plans' => function($query) {
            $query->join('shares', 'plans.share_id', '=', 'shares.id')- 
 >orderBy('shares.year', 'asc');
        }])
        ->has('plans')
        ->orderBy('Peoples.People_no', 'asc')
        ->where('Peoples.vesting_percentage', '>', 0)
        ->chunk(200, function($Peoples) use(&$fullPaths, $time){
            foreach ($Peoples as $People) {
                if (is_null($People->upple)) continue;

                if ($People->upple->STATUS == 1 or  $People->plans- 
>sum('shares') <=0) continue;

                $fileName = (trim($People->ssn) . '.' . $time . '.pdf');

                $this->PeopleReportGenerator->generate($People, $fileName);

                $fullPaths[] = config('esop.individual_statements_dir') . 
$fileName;
            }
        });

    $mergedPdfFullPath = config('esop.individual_statements_dir') . 
'inactive-participants.' . $time . '.pdf';

    passthru('cpdf ' . implode(' ', $fullPaths) . ' -o ' . 
$mergedPdfFullPath);

    return response()->download($mergedPdfFullPath);
}

如果我更改if ($People->upple->STATUS == 1以匹配活动功能,则if ($People->upple->STATUS != 1会像活动功能一样工作。我尝试将行更改为===!= 3(状态字段为1或3)。

0 个答案:

没有答案