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).