Require Signatures and Associate Them With Eloquent Models

  • Reading time ~ 3 min
  • 04.12.2022
Laravel pad signature is a package to sign documents associated with an Eloquent model and optionally generate certified PDFs.

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:

namespace App\Models;
 
use Creagia\LaravelSignPad\Concerns\RequiresSignature;
use Creagia\LaravelSignPad\Contracts\CanBeSigned;
 
class Delivery extends Model
{
    use RequiresSignature;
    // ...
}

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

<x-creagia-signature-pad
    border-color="#eaeaea"
    pad-classes="rounded-xl border-2"
    button-classes="bg-gray-100 px-4 py-2 rounded-xl mt-4"
    clear-name="Clear"
    submit-name="Submit"
/>

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

// Get the signature image path
$myModel->signature->getSignatureImagePath();
 
// Get the signed document path
$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

Original
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

I'm full stack laravel developer

I knew my call in programming back in 2006.

WORK EXPERIENCE
CONTACT
Ukraine, Lutsk
+380979856297