PHP code example of deegitalbe / laravel-trustup-io-sign

1. Go to this page and download the library: Download deegitalbe/laravel-trustup-io-sign library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

deegitalbe / laravel-trustup-io-sign example snippets

shell
php artisan vendor:publish --provider="Deegitalbe\TrustupIoSign\Providers\TrustupIoSignServiceProvider" --tag="config"
shell


namespace App\Models;

use Deegitalbe\TrustupIoSign\Contracts\Models\HasManyTrustupIoSignedDocumentRelatedModelContract;
use Deegitalbe\TrustupIoSign\Models\HasManyTrustupIoSignedDocumentRelatedModel;

class Ticket implements HasManyTrustupIoSignedDocumentRelatedModelContract
{
    use HasManyTrustupIoSignedDocumentRelatedModel;

    protected $casts = [
        "trustup_io_signed_document_uuids" => 'collection'

    ];

    public function getTrustupIoSignOriginalPdfUrl(): string
    {
        return 'https://eforms.com/download/2019/08/Service-Contract-Template.pdf';
    }

    public function getTrustupIoSignCallbackUrl(): string
    {
        return 'https://www.google.com';
    }
}
shell


namespace Deegitalbe\TrustupIoSign\Models;

use Illuminate\Support\Str;
use Deegitalbe\TrustupIoSign\Services\SignUrlService;
use Deegitalbe\TrustupIoSign\Facades\TrustupIoSignFacade;

trait IsTrustupIoSignedDocumentRelatedModel
{

    protected string $trustupIoSignCallback;
    protected string $trustupIoSignWebhook;

    /**
     * Getting model identifier
     */
    public function getTrustupIoSignModelId(): string
    {
        /** @var Model $this */
        return $this->uuid ??
            $this->id;
    }

    /**
     * Getting model type for media.trustup.io
     */
    public function getTrustupIoSignModelType(): string
    {
        /** @var Model $this */
        return Str::slug(str_replace('\\', '-', $this->getMorphClass()));
    }


    public function getTrustupIoSignAppKey(): string
    {
        return TrustupIoSignFacade::getConfig("app_key");
    }

    public function getTrustupIoSignWebHookUrl(): string
    {
        // use this adress for locale container 'trustup-io-ticketing/webhooks/trustup-io-sign/signed-document/stored'.
        return route("webhooks.trustup-io-sign.signed-document.stored");
    }

    public function getTrustupIoSignUrl(?string $callback = null, ?string $webhook = null): string
    {
        /** @var SignUrlService */
        $signUrlService = app()->make(SignUrlService::class);
        if ($callback) $this->setTrustupIoSignCallback($callback);
        if ($webhook) $this->setTrustupIoSignWebhook($webhook);

        return $signUrlService->generateUrl($this);
    }

    protected function setTrustupIoSignCallback(string $callback): self
    {
        $this->trustupIoSignCallback = $callback;
        return $this;
    }

    protected function setTrustupIoSignWebhook($webhook): self
    {
        $this->trustupIoSignWebhook = $webhook;
        return $this;
    }
}