Purchase order decorators

This commit is contained in:
David Bomba 2022-06-29 11:47:16 +10:00
parent 36a7290679
commit 73bb2c96db
2 changed files with 28 additions and 19 deletions

View File

@ -111,7 +111,7 @@ class InvitationController extends Controller
// $file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
$file = (new CreatePurchaseOrderPdf($invitation))->handle();
$file = (new CreatePurchaseOrderPdf($invitation))->rawPdf();
$headers = ['Content-Type' => 'application/pdf'];

View File

@ -88,6 +88,32 @@ class CreatePurchaseOrderPdf implements ShouldQueue
}
public function handle()
{
$pdf = $this->rawPdf();
if ($pdf) {
try{
if(!Storage::disk($this->disk)->exists($path))
Storage::disk($this->disk)->makeDirectory($path, 0775);
Storage::disk($this->disk)->put($file_path, $pdf, 'public');
}
catch(\Exception $e)
{
throw new FilePermissionsFailure($e->getMessage());
}
}
return $file_path;
}
public function rawPdf()
{
MultiDB::setDb($this->company->db);
@ -191,25 +217,8 @@ class CreatePurchaseOrderPdf implements ShouldQueue
info($maker->getCompiledHTML());
}
if ($pdf) {
return $pdf;
try{
if(!Storage::disk($this->disk)->exists($path))
Storage::disk($this->disk)->makeDirectory($path, 0775);
Storage::disk($this->disk)->put($file_path, $pdf, 'public');
}
catch(\Exception $e)
{
throw new FilePermissionsFailure($e->getMessage());
}
}
return $file_path;
}
public function failed($e)