i want to combined multi image/pdf to one single pdf file in laravel. i use Imagick packages, here is my code:
$document1 = DocCust::latest('created_at')->where('cus_id',$id)->where('type','1')->first();
$document2 = DocCust::latest('created_at')->where('cus_id',$id)->where('type','2')->first();
$file1= public_path().'/documents/user_doc/'.$id.'/'.$document1->doc_pdf;
$file2= public_path().'/documents/user_doc/'.$id.'/'.$document2->doc_pdf;
$path = public_path().'/documents/user_doc/'.$id;
$images = array($file1, $file2);
$pdf = new Imagick($images);
$pdf->setImageFormat('pdf');
$pdf->writeImages('combined.pdf', true);
its works perfectly, but the new file pdf is saved to 'public' folder. i want to save the new pdf into folder based on their id.
public/documents/user_doc/'.$id.'
i tried to change this code with path, but i get error failed to open stream not found file etc..
$pdf->writeImages($path.'/'.'combined.pdf', true);