Require Signatures and Associate Them With Eloquent Models

https://laravelnews.imgix.net/images/laravel-signature-pad.jpg?ixlib=php-3.3.1

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;

2 

3use Creagia\LaravelSignPad\Concerns\RequiresSignature;

4use Creagia\LaravelSignPad\Contracts\CanBeSigned;

5 

6class Delivery extends Model

7{

8 use RequiresSignature;

9 // ...

10}

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

1<x-creagia-signature-pad

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"

7/>

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

2$myModel->signature->getSignatureImagePath();

3 

4// Get the signed document path

5$myModel->signature->getSignedDocumentPath();

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

Laravel News