Require Signatures and Associate Them With Eloquent Models


October 18th, 2022

Require Signatures and Associate Them With Eloquent Models

Laravel pad signature is a package to require a signature associated with an Eloquent model and optionally generate certified PDFs.

This package works by using a RequiresSignature trait (provided by the package) on an Eloquent model you want to associate with a signature. Taken from the readme, that might look like the following:

1namespace App\Models;
3use Creagia\LaravelSignPad\Concerns\RequiresSignature;
4use Creagia\LaravelSignPad\Contracts\CanBeSigned;
6class Delivery extends Model
8 use RequiresSignature;
9 // ...

You can also generate PDF documents with the signature by implementing the package's ShouldGenerateSignatureDocument interface. You can use a blade file or a PDF file as the basis for the signature document template. See the readme for details.

Once you have the package set up, a blade component provides the needed HTML to render the signature pad (shown with customizations):

2 border-color="#eaeaea"
3 pad-classes="rounded-xl border-2"
4 button-classes="bg-gray-100 px-4 py-2 rounded-xl mt-4"
5 clear-name="Clear"
6 submit-name="Submit"

Once you've collected signatures from users, you can access the signature image and document on the model like so:

1// Get the signature image path
4// Get the signed document path

This package also supports certifying the PDF, and instructions are provided in the readme. You can learn more about this package, get full installation instructions, and view the source code on GitHub.

This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.