<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
roundly-consulting / sentinel-for-laravel example snippets
use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Sentinel\Concerns\HasSeals;
use RoundlyConsulting\Sentinel\Contracts\Sealable;
use RoundlyConsulting\Sentinel\Definition\SealBuilder;
final class Invoice extends Model implements Sealable
{
use HasSeals;
public static function defineSeals(SealBuilder $seals): void
{
$seals->seal('financial')->attributes('customer_id', 'currency', 'amount', 'status');
}
}
use RoundlyConsulting\Sentinel\Facades\Sentinel;
$invoice->isIntact(); // true when every seal verifies
Sentinel::for($invoice)->verifyOrFail(); // throws TamperedModelException otherwise
Route::get('/invoices/{invoice}', ShowInvoice::class)->middleware('sentinel.verified');
Sentinel::for($invoice)->verify();
// VerificationResult { status: Tampered, reason: 'mac', changedAttributes: ['a:amount'], … }
$invoice->update(['note' => 'x']); // TamperedModelException: refused until acknowledged
Sentinel::for($invoice)->by($admin)->because('INC-88: refund fixed by the DBA')->acknowledge();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.