### Install Sentinel for Laravel with Composer and Artisan Source: https://github.com/roundly-consulting/sentinel-for-laravel/blob/main/README.md Run these commands to install the package, publish configuration and migrations, and run migrations. Requires PHP 8.4+, Laravel 12 or 13, and SQLite, PostgreSQL, or MySQL. ```bash composer require roundly-consulting/sentinel-for-laravel php artisan sentinel:install # publishes config + migrations, prints the key lines for .env php artisan migrate ``` -------------------------------- ### Handle tampering: verify, update refusal, and acknowledge Source: https://github.com/roundly-consulting/sentinel-for-laravel/blob/main/README.md Verify a tampered model, observe that updates are refused until acknowledged, and acknowledge the tampering with an actor and reason. ```php 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(); ``` -------------------------------- ### Verify model integrity with isIntact, verifyOrFail, and sentinel.verified middleware Source: https://github.com/roundly-consulting/sentinel-for-laravel/blob/main/README.md Check if a model is intact, throw an exception if tampered, or protect routes with the sentinel.verified middleware. ```php 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'); ``` -------------------------------- ### Declare a seal on an Eloquent model using HasSeals Source: https://github.com/roundly-consulting/sentinel-for-laravel/blob/main/README.md Use the HasSeals trait and implement Sealable to define a seal with specific attributes. Every Eloquent write will seal the row. ```php 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'); } } ```