dpps0715 2018-12-11 22:04
浏览 38

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

I have a site using Laravel 5.0.35 that I have inherited that has two functions, active and inactive, that reads a database of people and looks at the status field to produce a PDF document.

The active function works but the inactive does not. It throws the following error:

FileNotFoundException in File.php line 41: The file ".../laravel/app/PDFs/individual/inactive-participants.1544562943.pdf" does not exist in File.php line 41

at File->__construct('.../laravel/app/PDFs/individual/inactive-participants.1544562943.pdf') in BinaryFileResponse.php line 91

at BinaryFileResponse->setFile('.../laravel/app/PDFs/individual/inactive-participants.1544562943.pdf', 'attachment', false, true) in BinaryFileResponse.php line 50

at BinaryFileResponse->__construct('.../laravel/app/PDFs/individual/inactive-participants.1544562943.pdf', '200', array(), true, 'attachment') in -ResponseFactory.php line 129

at ResponseFactory->download('.../laravel/app/PDFs/individual/inactive-participants.1544562943.pdf') in ReportsController.php line 200

The function looks like this:

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 I change if ($People->upple->STATUS == 1 to match the active function, if ($People->upple->STATUS != 1 it works as the active function should. I have tried changing the line to be === and != 3 (The status field is either 1 or 3).

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀