PHP code example of mmoollllee / laravel-consent-control

1. Go to this page and download the library: Download mmoollllee/laravel-consent-control 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/ */

    

mmoollllee / laravel-consent-control example snippets


'analytics' => [
    'label' => 'Analytics',
    'scripts' => [
        ['src' => 'https://www.googletagmanager.com/gtag/js?id=G-XXXX', 'async' => true],
    ],
    'inline_script' => "window.dataLayer = window.dataLayer || [];",
],

'version' => env('CONSENT_CONTROL_VERSION', 1), // set null to disable

// config/consent-control.php
'eloquent' => [
    'model' => App\Models\Setting::class,
    'field' => 'consent_settings',
    'record_id' => 1,
],

// The model needs a JSON cast:
protected $casts = ['consent_settings' => 'array'];

'banner' => [
    'reload_on_revoke' => true,                  // false: handle `consent-updated` yourself
    'keep_on_reset' => ['XSRF-TOKEN', 'cart_*'], // exact names, or prefixes ending in *
],
bash
php artisan vendor:publish --tag=consent-control-config
php artisan vendor:publish --tag=consent-control-assets
bash
php artisan vendor:publish --tag=consent-control-translations
bash
php artisan vendor:publish --tag=consent-control-assets   # → public/vendor/consent-control
bash
php artisan vendor:publish --tag=consent-control-views