Skip to content

Commit

Permalink
faulty method for converting asset acceptance to pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Godmartinz committed Feb 24, 2022
1 parent 292bf21 commit 533670f
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 3 deletions.
17 changes: 15 additions & 2 deletions app/Http/Controllers/Account/AcceptanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\CheckoutAcceptance;
use App\Models\Company;
use App\Models\Contracts\Acceptable;
use Barryvdh\DomPDF\PDF;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
Expand Down Expand Up @@ -95,7 +96,6 @@ public function store(Request $request, $id)
if (! Storage::exists('private_uploads/signatures')) {
Storage::makeDirectory('private_uploads/signatures', 775);
}

$sig_filename = '';
if ($request->filled('signature_output')) {
$sig_filename = 'siglog-'.Str::uuid().'-'.date('Y-m-d-his').'.png';
Expand All @@ -107,7 +107,6 @@ public function store(Request $request, $id)

if ($request->input('asset_acceptance') == 'accepted') {
$acceptance->accept($sig_filename);

event(new CheckoutAccepted($acceptance));

$return_msg = trans('admin/users/message.accepted');
Expand All @@ -118,7 +117,21 @@ public function store(Request $request, $id)

$return_msg = trans('admin/users/message.declined');
}
$sig_image=Storage::get('private_uploads/signatures/'.$sig_filename);
$this->SignatureEulaPDF($acceptance, $sig_image );

return redirect()->to('account/accept')->with('success', $return_msg);
}

public function SignatureEulaPDF($acceptance, $sig_image)
{
// When I compact the $data I at least get back an ipsum string in the error message that is recognized as an
// "unknown variable". 2nd param in load view should be the array of things you wanted rendered in the pdf.
$data = [
'eula'=> $acceptance->checkoutable->getEula(),
'signature' => $sig_image,
];
$pdf = PDF::loadView('account.accept.create', compact($data));
return $pdf->download('test.pdf');
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"alek13/slack": "^2.0",
"bacon/bacon-qr-code": "^2.0",
"barryvdh/laravel-debugbar": "^3.6",
"barryvdh/laravel-dompdf": "^1.0",
"doctrine/cache": "^1.10",
"doctrine/common": "^2.12",
"doctrine/dbal": "^3.1",
Expand Down
288 changes: 287 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class,

/*
* Package Service Providers...
Expand Down Expand Up @@ -396,6 +397,7 @@
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'PDF' => Barryvdh\DomPDF\Facade::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
Expand Down

0 comments on commit 533670f

Please sign in to comment.