PHP code example of goldnead / statamic-entitlements
1. Go to this page and download the library: Download goldnead/statamic-entitlements 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/ */
goldnead / statamic-entitlements example snippets
// routes/console.php or App\Console\Kernel
Schedule::command('entitlements:announce')->everyFifteenMinutes();
use Goldnead\Entitlements\Facades\Entitlements;
Entitlements::grant(
subject: $user, // any Eloquent model, or a SubjectReference
productSlug: 'chorleiter-kurs', // a free string; there is no catalogue
source: 'mollie', // a free string; see Sources
sourceRef: $payment->id, // the external id this grant came from
expiresAt: now()->addYear(),
);
Entitlements::grantPending($contact, 'warmup-guide', 'newsletter_optin', 'warmup-guide');
Entitlements::claimPending($grant); // true exactly once, under any concurrency
Entitlements::revoke($grant, 'Chargeback #1234', $actor);
Entitlements::restore($grant, $actor);
Entitlements::enterGracePeriod($grant, now()->addWeek());